0

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

Henrikh
  • 150
  • 2
  • 3
  • 11

4 Answers4

1

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)

GuyT
  • 4,316
  • 2
  • 16
  • 30
1

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.

Community
  • 1
  • 1
db-mobile
  • 306
  • 2
  • 8
1

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 ``

user1844933
  • 3,296
  • 2
  • 25
  • 42
1

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`";
Awlad Liton
  • 9,366
  • 2
  • 27
  • 53