Reputation: 168
Do you see any problem? I get this error.
$col = 360;
$col1 = 350;
$esim = 0;
$esim1 = 1;
mysql_query("INSERT INTO my_table ($col, $col1) VALUES('$esim', '$esim1')") or die(mysql_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 '360, 350) VALUES('0', '1')' at line 1
Upvotes: 0
Views: 37
Reputation: 9351
It is tested it is working :)
you have problem in your column name. it is treated as an integer value not as a column name.
$col = 360;
$col1 = 350;
Can you use backticks in name like :
$col = "`360`";
$col1 = "`350`";
Upvotes: 1
Reputation: 3417
Try this...
$col = "`360`";
$col1 = "`350`";
$esim = 0;
$esim1 = 1;
mysql_query("INSERT INTO my_table ($col, $col1) VALUES('$esim', '$esim1')") or die(mysql_error());
If column name is in number it should be enclosed with ``
Upvotes: 1
Reputation: 326
I guess you are suffering from the same problem as here: Can a number be used to name a MySQL table column?
Put your table and column names into backticks.
Upvotes: 1
Reputation: 4416
Change 'table' to `table`. The word 'table' is reserved. More info about reserved words: https://drupal.org/node/141051
Identifiers may begin with a digit but unless quoted may not consist solely of digits.
(http://dev.mysql.com/doc/refman/5.0/en/identifiers.html)
Upvotes: 1