I have the code:
$result = mysql_query("SELECT * from centres where area LIKE '%$town%'",$db);
while ($myrow = mysql_fetch_row($result)) {
echo blah
}
This works fine when $town equals 'London' but if it equals 'St John's Wood' which has an apostrophe in it, then it doesn't work.
In the database it is there as 'St John\'s Wood' but when I pass through 'St John\'s Wood' from the previous page it doesn't work. It doesn't work if I use stripslashes to remove the slash either.
Any ideas?
Cheers
James
$result = mysql_query("SELECT * from centres where area LIKE '%$town%'",$db);
while ($myrow = mysql_fetch_row($result)) {
echo blah
}
This works fine when $town equals 'London' but if it equals 'St John's Wood' which has an apostrophe in it, then it doesn't work.
In the database it is there as 'St John\'s Wood' but when I pass through 'St John\'s Wood' from the previous page it doesn't work. It doesn't work if I use stripslashes to remove the slash either.
Any ideas?
Cheers
James