Jump to content

Where clause like and apostrophe


MDanz

Recommended Posts

i'm not getting any results for the query.  I'm sure it has something to do with the apostrophe and back slashes

$search = "q test'yes";
$search = mysql_real_escape_string($search);
mysql_query("SELECT * FROM block WHERE name LIKE '%$search%' ORDER BY `id` DESC",$this->connect);

 

When i echo it out i get this

SELECT * FROM block WHERE name LIKE '%q test\\\'yes%' ORDER BY `id` DESC

Link to comment
https://forums.phpfreaks.com/topic/242298-where-clause-like-and-apostrophe/
Share on other sites

when i echo my select query i now get this.

 

SELECT * FROM test WHERE name='q test\'1' ORDER BY `id` DESC LIMIT 10

 

in the database i have a row with name = q test\'1 but it isn't retrieving data.

 

What do i have to change to get the query to retrieve the result.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.