Jump to content

sql error


hasek522

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/116748-sql-error/
Share on other sites

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());

 

Link to comment
https://forums.phpfreaks.com/topic/116748-sql-error/#findComment-600383
Share on other sites

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.