Jump to content

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

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.