Page 1 of 1

Query problem

Posted: Sat Jun 03, 2006 8:02 am
by ddragas
What's wrong with this query?

Code: Select all

<?

$vrsta = 1;

include('con_db.php');
mysql_query("ALTER TABLE kriteriji ADD COLUMN $vrsta TEXT NOT NULL") or die (mysql_error());

?>
I get error

Code: Select all

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 '1 TEXT NOT NULL' at line 1
Using MySql version 4.0.23

Posted: Sat Jun 03, 2006 8:30 am
by Weirdan

Posted: Sat Jun 03, 2006 8:37 am
by ddragas
You mean all numbers are invalid name as field name or just number 1?

Posted: Sat Jun 03, 2006 8:44 am
by Weirdan
here's excerpt from the manual:
MySQL manual wrote: A name may start with any character that is legal in a name. In particular, a name may start with a digit; this differs from many other database systems! However, an unquoted name cannot consist only of digits.

Posted: Sat Jun 03, 2006 8:49 am
by ddragas
Thank you for quick reply