samona Posted July 7, 2008 Share Posted July 7, 2008 $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. Quote Link to comment Share on other sites More sharing options...
rhodesa Posted July 7, 2008 Share Posted July 7, 2008 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 Quote Link to comment Share on other sites More sharing options...
bluejay002 Posted July 8, 2008 Share Posted July 8, 2008 yep... pls check if the fields you are to insert is empty or not. if its empty, just don't insert it at all, except you want to make it like that. anyway, use '' for string or null if ever you allowed one. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.