Jump to content

Could not add the entry because...???


cturner

Recommended Posts

I am getting the following error when I test the code that is below. I have commented out most of my code to find this error as I had other problems before this. Anyway can someone please look at the code that is below and tell me why I am getting this error? Thanks in advance.

Could not add the entry because: 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 ('0', 'cturner', 'chloe', '6 November 2006', 'C', 'Turner', 'Blue G' at line 1. The query was INSERT INTO `tbl_users` (`userid`, `user_username`, `user_password`, `user_regdate`, `user_firstname`, `user_lastname`, `user_company`, `user_address`, `user_towncity`, `user_state`, `user_postcode`, `user_country`, `user_phone`, `user_email`, `shipping_firstname`, `shipping_lastname`, `shipping_company`, `shipping_address`, `shipping_towncity`, `shipping_state`, `shipping_postcode`, `shipping_country`, `mailinglist`, `additional` VALUES ('0', 'cturner', 'chloe', '6 November 2006', 'C', 'Turner', 'Blue Gum Interactive', 'somewhere', 'else', 'nsw', 'postcode1', 'country1', '02 67555555, 'mail@domain.com', 'C', 'Turner', 'Blue Gum Interactive', 'somewhere', 'else', 'nsw', '2222', 'aus', 'checkbox', 'n/a').

[code=php:0]
if (isset($_POST['submit'])) {
$username = mysql_real_escape_string($_POST['username']);
$password = mysql_real_escape_string($_POST['password']);
$firstname1 = mysql_real_escape_string($_POST['firstname1']);
$lastname1 = mysql_real_escape_string($_POST['lastname1']);
$company1 = mysql_real_escape_string($_POST['company1']);
$address1 = mysql_real_escape_string($_POST['address1']);
$towncity1 = mysql_real_escape_string($_POST['towncity1']);
$state1 = mysql_real_escape_string($_POST['state1']);
$postcode1 = mysql_real_escape_string($_POST['postcode1']);
$country1 = mysql_real_escape_string($_POST['country1']);
$phone1 = mysql_real_escape_string($_POST['phone1']);
$email1 = mysql_real_escape_string($_POST['email1']);
// shipping details
$firstname2 = mysql_real_escape_string($_POST['firstname2']);
$lastname2 = mysql_real_escape_string($_POST['lastname2']);
$company2 = mysql_real_escape_string($_POST['company2']);
$address2 = mysql_real_escape_string($_POST['address2']);
$towncity2 = mysql_real_escape_string($_POST['towncity2']);
$state2 = mysql_real_escape_string($_POST['state2']);
$postcode2 = mysql_real_escape_string($_POST['postcode2']);
$country2 = mysql_real_escape_string($_POST['country2']);

$shippingmethod = mysql_real_escape_string($_POST['shippingmethod']);
$mailinglist = mysql_real_escape_string($_POST['mailinglist']);
$hearabout = mysql_real_escape_string($_POST['hearabout']);
$additional = mysql_real_escape_string($_POST['additional']);

$sql = "INSERT INTO `tbl_users` (`userid`, `user_username`, `user_password`, `user_regdate`, `user_firstname`, `user_lastname`, `user_company`, `user_address`, `user_towncity`, `user_state`, `user_postcode`, `user_country`, `user_phone`, `user_email`, `shipping_firstname`, `shipping_lastname`, `shipping_company`, `shipping_address`, `shipping_towncity`, `shipping_state`, `shipping_postcode`, `shipping_country`, `mailinglist`, `additional` VALUES ('0', '$username', '$password', '$date2', '$firstname1', '$lastname1', '$company1', '$address1', '$towncity1', '$state1', 'postcode1', 'country1', '$phone1, '$email1', '$firstname2', '$lastname2', '$company2', '$address2', '$towncity2', '$state2', '$postcode2', '$country2', '$mailinglist', '$additional')";
}
// more code here
mysql_close();
[/code]
Link to comment
Share on other sites

with all due respect, how can it not be totally obvious that you're missing a closing parenthesis in your query?  look before VALUES:  anything seem to be missing there?  the error often tells you exactly where MySQL choked, as it does here.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.