Reply to Re: Creating tables on-the-run

Your name:

Reply:


Posted by max on 08/14/05 16:48

First off, thanks for your patience.
>The . operator is to connect two strings: "test1"."test2" becomes "test1test2"
Of course! How dim can I get?
>
>> $TableName=rand(12345, 99999);
>> // which I thought would create $TableName with the value from the rand()
>
>Yes it does. But notice that you could have collisions. Imagine you get the random number
>20000 and you got it already? You already have the table!
No, in my clumsy kludgey way, I wanted to avoid possible collisions by
creating tables at random (I could always increase the seed range
enormously) while input is made, this is sent back to the user to verify
and, upon verification, the data is dumped into the table proper and the
rand-generated table dropped.
>
>> $Query = 'CREATE TABLE $TableName ('
>> . ' `id` SMALLINT(3) NOT NULL AUTO_INCREMENT, '
>> . ' `firstname` VARCHAR(255) NOT NULL,'
>> . ' PRIMARY KEY (`id`)'
>> . ' )';
>
>That looks right, but use " instead of ' instead and PHP will replace $TableName inside
>the string with the content of the variable $TableName. ' doesn't.
If you mean -
$Query = "CREATE TABLE $TableName ('
.. ' `id` SMALLINT(3) NOT NULL AUTO_INCREMENT, '
.. ' `firstname` VARCHAR(255) NOT NULL,'
.. ' PRIMARY KEY (`id`)'
.. ' )";

alas, that doesn't do it.

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация