|
Posted by Hilarion on 10/13/06 11:24
> > It is also possible to create table with names like 12345 with your script.
> Subsequent to reading Hilarion's helpful message, and experimenting to prove
> that a non-numeric character must be in the table name, I proved to my own
> satisfaction that, contrary to what you say, it is not possible to create a
> table with my code. If it were, I would not have asked my original
> question.
Stefan is right. You can create MySQL table with only digits in it's name.
You noticed that phpMyAdmin can and phpMyAdmin is written in PHP, so it's
possible to create such table with PHP. The difference is that you have
to enclose the table name in the "CREATE TABLE..." query in "`" signs
when it consists only of digits.
This:
$Query = "CREATE TABLE `$TableName` ("
. ' id SMALLINT(3) NOT NULL AUTO_INCREMENT, '
. ' firstname VARCHAR(255) NOT NULL,'
. ' PRIMARY KEY ( id )'
. ' )';
should work with $TableName being only digits.
Your original problem came not from it being only digits but from
incorrect usage of quotes (single and/or double).
I suggested using textual prefix not because it's required, but
because it makes table names more readable ("temp_123" name
makes it obvious that it's a temporary table) and makes the query
work also in other SQL engines (cause some do not accept plain
numbers as table names).
Hilarion
Navigation:
[Reply to this message]
|