This has been asked a lot here, but I can't seem to find the problem....
I wanted to submit my FormMail.php to a MySQL database using php.
Getting the error:
Error=Insert failed: 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 ''FullName', 'EmailAddr', 'contact', 'colors', 'vehicles', 'mesg', 'email', 'rnam' at line 1
<?php
$con = mysql_connect("localhost","root","db79ax4");
if (!$con)
{
Error('database','Could not connect: ' . mysql_error()); /* this also exits the script */
}
$FullName = mysql_real_escape_string($aCleanedValues['FullName'],$con);
$EmailAddr = mysql_real_escape_string($aCleanedValues['EmailAddr'],$con);
$contact = mysql_real_escape_string($SPECIAL_VALUES['contact'],$con);
$colors = mysql_real_escape_string($SPECIAL_VALUES['colors'],$con);
$vehicles = mysql_real_escape_string($SPECIAL_VALUES['vehicles'],$con);
$mesg = mysql_real_escape_string($SPECIAL_VALUES['mesg'],$con);
$email = mysql_real_escape_string($SPECIAL_VALUES['email'],$con);
$rname = mysql_real_escape_string($SPECIAL_VALUES['rname'],$con);
mysql_select_db("resourcentr", $con);
$sql="INSERT INTO johnwork ('FullName', 'EmailAddr', 'contact', 'colors', 'vehicles', 'mesg', 'email', 'rname')
VALUES
('$FullName','$EmailAddr','$contact','$colors','$vehicles','$mesg','$email','$rname')";
if (!mysql_query($sql,$con))
{
Error('database','Insert failed: ' . mysql_error()); /* this also exits the script */
}
mysql_close($con);
Any ideas? Is there something wrong with the above code? Thanks!