View Full Version : Mysql giving error with '

09-16-2006, 08:09 AM
I have built a php script that inserts data into a mysql table but everytime I try and insert data with an ' it returns an error:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 's', 'step')' at line 2

in this particular case I was trying to insert the word "dave's"

What's going on? any help woud be appreciated Thanks

09-16-2006, 08:22 AM
you need to escape your quotes.
If you're using PHP then wrap your values in mysql_real_escape_string() - it will escape all characters that will throw up these errors.
If you dont have mysql_real_escape_string - try addslashes()


09-16-2006, 08:30 AM
That did it. Thank you very much