...

View Full Version : Mysql giving error with '



Jacobb123
09-16-2006, 07: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

NancyJ
09-16-2006, 07: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()

http://uk.php.net/mysql_real_escape_string
http://uk.php.net/manual/en/function.addslashes.php

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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum