MDanz Posted July 19, 2011 Share Posted July 19, 2011 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 More sharing options...
ebmigue Posted July 19, 2011 Share Posted July 19, 2011 Most probably you magic_quotes enabled. Thus, when you try to mysql_real_escape it, there is an additional backslash. In short, a double backslash. Disable the feature, and perhaps the problem will be solved. Link to comment https://forums.phpfreaks.com/topic/242298-where-clause-like-and-apostrophe/#findComment-1244406 Share on other sites More sharing options...
MDanz Posted July 19, 2011 Author Share Posted July 19, 2011 i tried but i get the internal 500 server error i put this in my .htaccess file php_flag magic_quotes_gpc off Link to comment https://forums.phpfreaks.com/topic/242298-where-clause-like-and-apostrophe/#findComment-1244412 Share on other sites More sharing options...
ebmigue Posted July 19, 2011 Share Posted July 19, 2011 Hmm... In short, there is something wrong with the server's setup (w/c PHP might not have involvement with). It would be wise to refer this to your hosting provider's tech. support. Hope it helps. Link to comment https://forums.phpfreaks.com/topic/242298-where-clause-like-and-apostrophe/#findComment-1244429 Share on other sites More sharing options...
MDanz Posted July 20, 2011 Author Share Posted July 20, 2011 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. Link to comment https://forums.phpfreaks.com/topic/242298-where-clause-like-and-apostrophe/#findComment-1244975 Share on other sites More sharing options...
fenway Posted July 21, 2011 Share Posted July 21, 2011 Well, if your value has a backslash, you'll need to escape it, too. Link to comment https://forums.phpfreaks.com/topic/242298-where-clause-like-and-apostrophe/#findComment-1245554 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.