Hi,
I'm having problems retrieving rows from a table when the search criteria contains an apostrophe ('). I have been reading the other threads concerning this problem and I unfortunately haven't found anything that has helped.
Code:
if ($_POST['titulo']){
$clean['titulo'] = mysql_real_escape_string(trim($_POST['titulo']));
$sqlExtra .= " AND (titulo LIKE '".$clean['titulo']."%' OR titulo LIKE '% ".$clean['titulo']."%' OR titulo LIKE '%=".$clean['titulo']."%')";
}
So if I type in "Don't do that" it says that it doesn't exist when it does...
In the table, the inserts are done in a similar manner and I don't save any escape characters .
Using phpMyAdmin, the query works when I manually add the slashes (as it should) but the code doesn't want to add them. The real problem is in that on the server, magic_quotes are ON and I can't change that for various reasons, so I have been trying unsuccessfully to change that in the script using
ini_set ('magic_quotes_gpc', 0);
set_magic_quotes_runtime (0);
This seems to do absolutely nothing as the following code (taken from php.net) shows:
ini_set ('magic_quotes_gpc', 0);
echo get_magic_quotes_gpc();
echo "<br />";
echo $_POST['titulo'];
echo "<br />";
echo addslashes($_POST['titulo']);
The output is
1
Don't
Don't
Is there anything obvious that I may be missing? Woods for trees come to mind..
Thanks