Jump to content

SQL syntax error


scotch33

Recommended Posts

Hi,

I am getting 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 'invoiceno='123456', amount='23.00', name='test', email='john@john.co.uk', phone=' at line 3

when using the following code -

[code] $sql_insert = "INSERT INTO payment_records SET
rand_code='$randcode'
invoiceno='$invoiceno',
amount='$amount',
name='$name',
email='$email',
phone='$phone',
companyname='$companyname',
billingaddress='$billingaddress',
billingpostcode='$billingpostcode',
addresschange='$addresschange'";[/code]

apparently the version of mysql has recently been upgraded to 4.3.10 - I have tried to find refernce to any difference in comands but haven't had a lot of luck.  Can anyone point me in the right direction?
Link to comment
Share on other sites

Try using...

[code]$sql_insert = "insert into payment_records values('$randcode', '$invoiceno', '$amount', $name', $email', $phone', $companyname', $billingaddress', '$billingpostcode', $addresschange'";[/code]

...if you're placing the values into all of the table columns.  If you're not placing the values into all of the columns in your table, then you need to specify which colums to insert by...

[code]$sql_insert = "insert into payment_records(columns go here) values('$randcode', '$invoiceno', '$amount', $name', $email', $phone', $companyname', $billingaddress', '$billingpostcode', $addresschange')";[/code]
Link to comment
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.