Jump to content

Insert into table error


m.huber614

Recommended Posts

I keep getting this 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 'VALUES ('1234567890000','adsf','asdf','sdaf','asdfasdf','sdfsa','safsd','sfsa','' at line 2My form is here:<form action="insert.php" method="post">Acct#: <input type="text" name="acctnum" />Rep ID: <input type="text" name="repid" />Rep Name: <input type="text" name="repname" />Previous Service: <input type="text" name="prevserv" />Offer Code: <input type="text" name="offercode" />Customer Name: <input type="text" name="custname" />Customer Address: <input type="text" name="custaddr" />Customer Phone Number: <input type="text" name="custphone" />Customer Zip Code: <input type="text" name="custzip" />Credit Card Type: <input type="text" name="credittype" />Last 4 Digits of Credit Card: <input type="text" name="creditlast4" />How was the sale received?: <input type="text" name="salercvd" />Order Date: <input type="text" name="orderdate" />Install Date: <input type="text" name="installdate" /><input type="submit" /></form>PHP snippet here:mysql_select_db("tvbscustomer", $con);$sql="INSERT INTO Sales (Acct#, Rep ID, Rep Name, Prev Serv, Offer Code, Cust Name, Cust Addr, Cust Phone, Cust Zip, Credit Type, Credit Last 4, Sale Rcv'd, Order Date, Install Date)VALUES('$_POST[acctnum]','$_POST[repid]','$_POST[repname]','$_POST[prevserv]','$_POST[offercode]','$_POST[custname]','$_POST[custaddr]','$_POST[custphone]','$_POST[custzip]','$_POST[credittype]','$_POST[creditlast4]','$_POST[salercvd]','$_POST[orderdate]','$_POST[installdate]')";Any ideas? I'm new to databasing so pardon if the code is sloppy or makes no sense.

Link to comment
Share on other sites

I'm not sure if you're allowed to use characters like # and ' in field names, but if it let you create the table like that then I guess it will work. But any time you have a field name with a space in it you need to put it in `backquotes`.

Link to comment
Share on other sites

I'm not sure if you're allowed to use characters like # and ' in field names, but if it let you create the table like that then I guess it will work. But any time you have a field name with a space in it you need to put it in `backquotes`.
You can't, I think they were the problem. Godaddy puts the backquotes in for you. It works beautifully now, thank you!
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...