note 62127 deleted from function.addslashes by nlopess
| From: | nlopess@php.net | Date: | Wed, 08 Mar 2006 10:23:25 +0000 |
| Subject: | note 62127 deleted from function.addslashes by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-105037@lists.php.net to get a copy of this message | ||
Note Submitter: mike at gorillasoft dot com
----
Don't waste your time on this like I did:
If you are comparing strings in a query on mySQL and the stored column has been escaped by
addslashes you might have some problems. It was not simply good enough to addslashes once to the
comparison variable but twice;
MySql does not account for the escaped characters.
$temp = 'Mike's Notes';
t1 * textColumn
**************
r1 * Quick Notes
r2 * Mike\\'s Notes
$sqlQuery = "select * from t1 where textColumn = '".addslashes($temp)."';
//returns no rows!
$sqlQuery = "select * from t1 where textColumn =
'".addslashes(addslashes($temp))."';
//returns 1 row!