Jump to content

[SOLVED] Help MySQL statement error


samona

Recommended Posts

$query = "INSERT INTO Table(`Neg_Thirty`,`Neg_Twentyfive`, `Neg_Twenty`, `Neg_Fifteen`, `Neg_Ten`, `Neg_Five`, `Zero`, `Five`, `Ten`, `Fifteen`, `Twenty`, `Twentyfive`, `Thirty`,`Name`,`Table.
Current_Date`, `Type`) VALUES ({$_POST['neg_thirty']},{$_POST['neg_twentyfive']},{$_POST['neg_twenty']},{$_POST['neg_fifteen']},{$_POST['neg_ten']},{$_POST['neg_five']},{$_POST['zero']},{$_POST['five']},{$_POST['ten']},{$_POST['fifteen']},{$_POST['twenty']},{$_POST['twentyfive']},{$_POST['thirty']},'{$_POST['name']}',NOW(), \'Type\'";

 

I get an error saying

 

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 ',,,,,,,,,,,,'adsf',NOW(), \'Type\'' at line 1

 

adsf is the value I entered for {$_POST['name']}'

 

Please advise.

Link to comment
Share on other sites

as far as i know, you can't have commas next to each other like that. it needs to have NULL or '' (that is two single quotes)

 

try this:

$query = "INSERT INTO Table(`Neg_Thirty`,`Neg_Twentyfive`, `Neg_Twenty`, `Neg_Fifteen`, `Neg_Ten`, `Neg_Five`, `Zero`, `Five`, `Ten`, `Fifteen`, `Twenty`, `Twentyfive`, `Thirty`,`Name`,`Table.
Current_Date`, `Type`) VALUES ('{$_POST['neg_thirty']}','{$_POST['neg_twentyfive']}','{$_POST['neg_twenty']}','{$_POST['neg_fifteen']}','{$_POST['neg_ten']}','{$_POST['neg_five']}','{$_POST['zero']}','{$_POST['five']}','{$_POST['ten']}','{$_POST['fifteen']}','{$_POST['twenty']}','{$_POST['twentyfive']}','{$_POST['thirty']}','{$_POST['name']}',NOW(),'Type'";

i also removed the \ around Type since they looked like they didn't belong

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.