Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

I have written the below query in a function:

 $dsearch=mysql_real_escape_string($condition['title']);
 "select id, title , category, little, strip_tags('description') AS strip_desc,flag , 
       POSITION('$dsearch' IN title) AS pos_title,
       POSITION('$dsearch' IN strip_desc) AS pos_desc, 
    from    tbl_contents 
    where  title RLIKE  '[[:<:]]".$dsearch."[[:>:]]'
           description RLIKE  '[[:<:]]".$dsearch."[[:>:]]' 
    order by priority desc"

But the "strip_tags" does not work and I get errors. Is the method for this query wrong? thanks for your help in advance.

@il_raffa I get this error: FUNCTION myDBname.strip_tags does not exist Warning: mysql_fetch_assoc() expects parameter 1 to be resource – For.oi Oct 4, 2015 at 7:37 @F.Ahmadi Are you really trying to apply strip_tags on a column in your table? And then second error mysql_fetch_assoc() expects parameter 1 to be resource is the reason of your first failure (query failed). – DirtyBit Oct 4, 2015 at 7:48

MySQL does not provide a function called strip_tags.
Assuming you use access your database using PHP, you can use the PHP function strip_tags on each row you fetched:

$strip_desc = strip_tags($row['description']);

See here:
What is the MySQL query equivalent of PHP strip_tags?

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.