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='[email protected]', 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
https://forums.phpfreaks.com/topic/36482-sql-syntax-error/
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
https://forums.phpfreaks.com/topic/36482-sql-syntax-error/#findComment-173646
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.