Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
safe_rows question
OK – so I have the following mysql querie but it is failing
$query = safe_rows('name, title', 'txp_category', 'type like "image" AND name!="root" AND name!="peaches-and-cream"');
It is failing due to the name with hypens, if I remove it, it works fine, if I add another category name without hyphens, it works fine.
Am I doing something wrong here?
Offline
Re: safe_rows question
You should probably escape the query (“peaches\-and\-cream”) with doSlash().
Offline
Re: safe_rows question
Thanks etc – that worked perfectly :)
I couldn’t find any info on doSlash(), but tried addslashes() and that worked :)
Offline
Re: safe_rows question
tye wrote:
I couldn’t find any info on doSlash(), but tried addslashes() and that worked :)
As Nathan Drake would say No no no no no. doSlash() is Textpattern’s core function and is used to escape quoted values used in SQL statements. You really should use it instead of addslashes()
, which is not exactly the correct tool (or safe either).
Last edited by Gocom (2012-06-07 11:26:08)
Offline
Re: safe_rows question
whoops…. hides :)
Thanks Jukka – I’ll check it tomorrow :)
Offline
Pages: 1