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
Share on other sites

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
Share on other sites

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
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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.