SQL Error

I am trying to put the following into a database

[php]
mysql_query(“INSERT INTO bookings (bookingRef,fName,sName,add,townCity,county,country,postcode,telNum,mobNum,eMail,guests,from,to) VALUES (’$bookingRef’,’$fName’,’$sName’,’$add’,’$townCity’,’$county’,$country’,’$postcode’,’$telNum’,’$mobNum’,’$eMail’,’$guests’,’$from’,’$to’)”)
or die(mysql_error());
[/php]

but am getting the following 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 'add,townCity,county,country,postcode,telNum,mobNum,eMail,guests,

any suggestions

from is a keyword in mysql if u use a field called from u have to use quotes.
it’s good practice to enclose all fieldnames in quotes. and i would sugesst not using a field called from.
[php]
mysql_query(“INSERT INTO bookings (bookingRef,fName,sName,add,townCity,county,country,postcode,telNum,mobNum,eMail,guests,sender,to) VALUES (’$bookingRef’,’$fName’,’$sName’,’$add’,’$townCity’,’$county’,$country’,’$postcode’,’$telNum’,’$mobNum’,’$eMail’,’$guests’,’$from’,’$to’)”)
or die(mysql_error());
[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service