Trouble inserting text with commas into mysql

I have a simple mysql insert statement:

“insert into movies values(‘$title’,‘$category’,‘$user’,‘$type’)”

I know this works. However, when my title has a comma in it (such as The Devil’s Advocate) the statement won’t execute. When I use phpmyadmin I can input it that way. This makes me think it’s a php, rather than a mysql issue.

Any takers?

addslashes($title);

would equal “the devil\'s advocate” which will include the ’ but not use it as code.

Yeah, you should always use the addslashes() function when inserting any kind of text into a table. Then, when retrieving the information, make sure to use the stripslashes() function to ‘strip’ the data of slashes that were added to the data before it was put into the data. This helps against an SQL Injection attack.

That’s an apostrophe or single quote, not a comma. A comma is a “,”.

Better to use the function that exists specifically to prepare input for MySQL queries:

mysql_real_escape_string()

Thanks Arkinstall, that did it

not needed. the database will strip the slashes when storing the data.
if you have personally needed to use stripslashes() on data coming from a database, its because you double escaped it. this is most likely because you have magic_quotes turned on, and then you used addslashes() again without checking if you needed to do so with get_magic_quotes_gpc()