hasek522 Posted July 26, 2008 Share Posted July 26, 2008 Here is my sql statement: I just cant seem to figure out what is wrong with this. $sql = "INSERT INTO accounts (userid,name,description,expenses,profits,balance,starting) VALUES( '" . $id . "', '" . $name. "', '" . $description . "', '" . 0 . "', '" . 0 . "', '" . $_POST['balance'] . "', '".$_POST['balance'].")"; mysql_query($sql) or die(mysql_error()); Here is the 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 'starting) VALUES( '1', 'testsasdas', 'asdasd', '0', '0', '120', '120)' at line 1 Quote Link to comment https://forums.phpfreaks.com/topic/116748-sql-error/ Share on other sites More sharing options...
paul2463 Posted July 26, 2008 Share Posted July 26, 2008 if you look closly at the error being reported, you will see that the last 120 does not have a closing single tick on it, then go and have a look at your query code you will also see that there is a closing single tick missing after the double ticks before the closing brace......try this $sql = "INSERT INTO accounts (userid,name,description,expenses,profits,balance,starting) VALUES( '" . $id . "', '" . $name. "', '" . $description . "', '" . 0 . "', '" . 0 . "', '" . $_POST['balance'] . "', '".$_POST['balance']."')"; mysql_query($sql) or die(mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/116748-sql-error/#findComment-600383 Share on other sites More sharing options...
hasek522 Posted July 26, 2008 Author Share Posted July 26, 2008 thanks for the reply, but i tried your code and got this: 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 'starting) VALUES( '1', 'Tester123', 'asdasd', '0', '0', '12' at line 1 Quote Link to comment https://forums.phpfreaks.com/topic/116748-sql-error/#findComment-600398 Share on other sites More sharing options...
PFMaBiSmAd Posted July 26, 2008 Share Posted July 26, 2008 The point where the syntax error was detected is always right after the near ' in the error message. In your case starting is a reserved keyword. Quote Link to comment https://forums.phpfreaks.com/topic/116748-sql-error/#findComment-600405 Share on other sites More sharing options...
hasek522 Posted July 26, 2008 Author Share Posted July 26, 2008 o wow cool thanks Quote Link to comment https://forums.phpfreaks.com/topic/116748-sql-error/#findComment-600423 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.