Hello,

Regarding this code:
[PHP code]
  // This works
  $name="name";
  $table="mytable";
  $mysql_connect("localhost","","") or die("Error: ".mysql_error());
  $mysql_select_db("mydb") or die("Error: ".mysql_error());
  $mysql_query("INSERT INTO $table (`id`,`name`) VALUES ('','$name')");
[/PHP code]

I want to define() TABLE as a constant instead of using the variable $table

[PHP code]
  // This runs without an error but does *not* insert a new row
  $name="name";
  define("TABLE", "mytable");
  $mysql_connect("localhost","","") or die("Error: ".mysql_error());
  $mysql_select_db("mydb") or die("Error: ".mysql_error());
  $mysql_query("INSERT INTO TABLE (`id`,`name`) VALUES ('','$name')");
[/PHP code]

Changing the query line to
  $mysql_query("INSERT INTO `TABLE` (`id`,`name`) VALUES ('','$name')");
or
  $mysql_query("INSERT INTO 'TABLE' (`id`,`name`) VALUES ('','$name')");
has no effect.

I also tried to
  define("TABLE", "`mytable`");
which, too, didn't work.

Would appreciate any advice,
 Ben

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to