You have an error in your SQL syntax

I am getting this error on my results page for a form:

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 'references, insurance, namedate) VALUES (‘test’,‘test’,‘test’,'t

This is my code:


 <?php
$con = mysql_connect("mysql","*****","*****");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }mysql_select_db("dasher", $con);$sql="INSERT INTO vendor (cname, maddress, paddress, supplies, bphone, cphone, fax, email, conname, capacity, contactcellphone, statetax, fedtax, ssn, lengthbusiness, license, residence, references, insurance, namedate)
VALUES
('$_POST[cname]','$_POST[maddress]','$_POST[paddress]','$_POST[supplies]','$_POST[bphone]','$_POST[cphone]','$_POST[fax]','$_POST[email]','$_POST[conname]','$_POST[capacity]','$_POST[contactcellphone]','$_POST[statetax]','$_POST[fedtax]','$_POST[ssn]','$_POST[lengthbusiness]','$_POST[license]','$_POST[residence]','$_POST[references]','$_POST[insurance]','$_POST[namedate]')";if (!mysql_query($sql,$con))
  {
  die('Error: ' . mysql_error());
  }
echo "Your application is being reviewed.";mysql_close($con)
?>

I’m not seeing any problems. Am I missing something?

Thanks!

“references” is a reserved word. You’ll need to change that or put it in backticks.

That was it! Thanks man! I have another question. Would it be possible to export the table into an organized form so that it isn’t just rows of data? This would be so my client can easily look over the information submitted.

how is rows of data not organized already? You’d have to clarify what you want your client to look at for us to decide how to answer that question.

What I’m talking about is a proper form like you would have on a print out. My client gave me a print out of their form, and I made a form on the website. So could they be able to see an export that looks similar to their form that’s on paper? So that they maybe could print that out.

You can export database content in a few formats, but they are for backing up or moving, not really for human consumption, unless maybe if you like reading raw CSV :wink:

What you want is to put together a SELECT query to get what you want and have some sort of script format it.

Although MySQL can allow for some fine tuning, it really depends mostly on what language you’re working with.

I’ll give that a shot. Thanks!