Strip_tags from substring in query

Hello,

how can i target the substring in a query to remove the html (strip_tags) code in it (like ,

,

, etc).

I have

$produse_q = " SELECT SQL_CALC_FOUND_ROWS DISTINCT
at_id AS rank,
produse., SUBSTRING(produs_description, 1, 200) as ‘produs_descriere_scurta’,
firme.
,
categories.*
FROM produse"

and on html page

{produse.produs_descriere_scurta}

I think you answered yourself there…

http://php.net/strip_tags
http://php.net/substr

I wouldn’t user substring in mysql, get the result and then play with it.

Well, it’s not my code, and i need to solve a bug in which the page gets weird artefacts due to html code being parsed from descriptions.

And thanks (i guess) for the links which i already read a bunch of times. Not very helpfull :confused:

Well, since i’ve never used SQL_CALC_FOUND_ROWS or SUBSTRING (in MySQL) I can’t really help you fix that code, if you could explain the problem and the desired solution maybe I, or someone else, could come up with an alternate solution.

Get your data first, then run it through PHP’s strip_tags.

http://php.net/strip_tags

Mysql substring only returns part of a string, it’s not a function for replacing/escaping strings. You could probably look into creating some function using mysql replace, or something. See some examples here: http://stackoverflow.com/questions/7654436/what-is-the-mysql-query-equivalent-of-php-strip-tags

fBut it would still be wrong.

Escaping belongs in the view, not in the database query.

Sponsor our Newsletter | Privacy Policy | Terms of Service