Jump to content


MySql Error on Updating when 'this' quotation mark in variable

  • Please log in to reply
1 reply to this topic

#1 casbboy

  • Members
  • PipPip
  • Member
  • 15 posts

Posted 23 May 2006 - 06:19 AM

I have a php update like this:

$upsql = mysql_query("UPDATE comments SET comment2='$oldcomment', comment='$newcomment', edited='y', verified='$verified' WHERE user_id='$userid' AND edited='n' AND comment_id='$commentid'", $connection)
or die(mysql_error());

The problem is that $oldcomment features a ton of text that has both "this" type of quotation marks and 'this' type of quotation marks. I get a mysql error because of these quotation marks when trying to update the database.

I have done a string replace to pull them out just for testing sake and the update works fine... so it is the existance of the quotation marks that are causing issues.

i NEED these quotation marks to remain, but how can I do the update query and avoid the error?


Again, thanks for all the help I recieve

#2 fenway

  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 23 May 2006 - 08:14 PM

You have to escape these quotes -- the DB wrapper can handle this, or PHP can handle this, or you can do it yourself.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users