Page 1 of 1

Problem with single quotes in mysql db

Posted: Mon Mar 15, 2004 7:51 am
by chriso
I have a table called crs_desc with a data type of longtext. When I bring up this field in a form to be edited the text is surrounded by single quotes. For example:

'This is a bogus course for messing with'

Now, if I edit the text and delete the single quotes the text is updated with no problems. However, if I don't delete the single quotes, I get the following error message:

Error updating course information: 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 'This is a bogus course for messing with'' WHERE ID = '36'' at

Is there a way I can remove the single quotes before displaying the text for editing or is there another data type I should be using? I don't have to use longtext so I'm open for other datatypes. However, I don't want to limit the field to 255 char. because the course description may be longer than that.

BTW, when I display the field in an html document for just viewing, the single quotes are not displayed. It's only when its displayed in a form field that they appear.

Thanks for the help!

Posted: Mon Mar 15, 2004 9:19 am
by Steveo31
I think this may help you.
http://www.mysql.com/doc/en/BLOB.html

What is the rest of the code?

Posted: Mon Mar 15, 2004 9:43 am
by chriso
Maaaaannnnn!! 8O I can't believe I did that :oops: In my code I put the single quotes around the variable. Don't know what I was thinking. Took them out and all is well. :D Silly me.

Regards,
Chris.