Jump to content

Parse Error with Insert File


Twill1989

Recommended Posts

Hi,I'm the webmaster for a organization at my school. I've been working on developing a online enlistment form for our organization, but I can't seem to get the coding correct. I worked on it for months and I have had no progress at all. This is the error I'm constantly getting:

Parse error: parse error, expecting `']'' in ... on line 12
Here is the insert file:
<?php$con = mysql_connect("...","...","...");if (!$con) { die('Could not connect: ' . mysql_error()); }mysql_select_db("...", $con);$sql="INSERT INTO person (Name, Phone Number, Email Address, Shirt Size, Grade, HonorsAP, GPA, Transportation, Why)VALUES('$_POST[Name]','$_POST[Phone Number]','$_POST','$_POST[shirt Size]','$_POST[Grade]','$_POST[HonorsAP]','$_POST[GPA]','$_POST[Transportation]','$_POST[Why]')";if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); }echo "1 record added";mysql_close($con)?>
Can anyone tell me what I'm doing wrong? I can get the code to work if I use a smaller number of text fields. For example, if I have only four or five things to fill in, everything works fine. But with the nine I have, I always get the above error. Thanks
Link to comment
Share on other sites

I tried, another error:

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 'Number, Email Address, Shirt Size, Grade, HonorsAP, GPA, Transpo
Here is what the new insert file looks like:
<?php$con = mysql_connect("...","...","...");if (!$con) { die('Could not connect: ' . mysql_error()); }mysql_select_db("...", $con);$sql="INSERT INTO person (Name, Phone Number, Email Address, Shirt Size, Grade, HonorsAP, GPA, Transportation, Why)VALUES('{$_POST['Name']}','{$_POST['Phone Number']}','{$_POST['Email Address']}','{$_POST['Shirt Size']}','{$_POST['Grade']}','{$_POST['HonorsAP']}','{$_POST['GPA']}','{$_POST['Transportation']}','{$_POST['Why']}')";if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); }echo "1 record added";mysql_close($con)?>
Link to comment
Share on other sites

It may be because your column name has a space in it. Either update your column names so that there aren't any spaces (e.g. "PhoneNumber") or - some MySQL expert, please correct me if I'm wrong - try putting ` around the column names in your query:

INSERT INTO person (Name, `Phone Number`, `Email Address`, `Shirt Size`, Grade, HonorsAP, GPA, Transportation, Why)VALUES

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...