Jump to content

can't search table when apostrophes present


ianco

Recommended Posts

Hi all.

 

I've been looking at this for several hours not with no progress. I feel it should be simple but I'm getting nowhere.

 

Here's the problem. I want to provide a list of links where from a table called pages.

 

When $title = "Dave's comment"; for example I get nothing back. If there is no apostrophe in the field it works fine. It's as though I can't find the field.

 

$query = mysql_query("SELECT * FROM pages WHERE title = '$title' ORDER BY pageid DESC LIMIT 20");


while($row = mysql_fetch_assoc($query)) {
  $title = $row['title'];
  echo $title;
}

 

any ways around this?

 

Thanks

Ian

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.