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
https://forums.phpfreaks.com/topic/113618-solved-help-mysql-statement-error/
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

Archived

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

×
×
  • 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.