I’m making a form in php that has a title and description area.
When I submit the form and try to insert the data to MYSQL I get an error wich seems to be due to a semicolon in the title.
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 Club’,
‘Design and Develop’, ‘1’)’ at line 1
Query
INSERT INTO Projects (ID, Title, Description, Status)
VALUES (0, 'Women's Club', 'Description of Project', '1')
Im trying to use mysql_real_escape_string() but im still getting this error.
Is there another method I need to be using to allow for semicolons to be inserted into mysql?
Here is some of the code im using.
$desc = mysql_real_escape_string($_POST['desc']);
$q = "INSERT INTO Projects (ID, Title, Description, Status)
VALUES (0, '$title', '$desc', '1')";
Thank you for your help.
The error is not with your
$desc. Instead it is with your$title.Add this line too:
just before insert query.
ON A SIDE NOTE: Don’t use
mysql_*functions. They have been deprecated.