You are here: Creating tables on-the-run « PHP SQL « IT news, forums, messages
Creating tables on-the-run

Posted by max on 08/13/05 11:40

Of the things I've done with php and MySQL, I've never yet been called upon
to create tables on the run with the table names generated at random. I
essayed this trial, but it doesn't seem to work; the table isn't created and
the routine naturally returns the error message shown. I've been looking at
the screen so long, my eyes are crossed.
What (doubtless double-plus-silliness) am I guilty of?
TIA.

<?
$TableName=rand(12345, 99999);
- connection string -

$Query = 'CREATE TABLE $TableName ('
. ' `id` SMALLINT NOT NULL, '
. ' `firstname` VARCHAR(255) NOT NULL'
. ' )';

$Result=mysql_db_Query ($DBName, $Query, $Link);
?>
<table><tr><td>
<?
print("$TableName");
?>
</td></tr></table>
<?
$Query="INSERT into $TableName (id, firstname) values ('5', '6')";
$Result=mysql_db_Query ($DBName, $Query, $Link);

$Query="SELECT * FROM $TableName";
$Result=mysql_db_query ($DBName, $Query, $Link);

while ($Row=mysql_fetch_array ($Result))
{
print("<table><tr><td>");
print("$Row[id] $Row[firstname]");
print("</td></tr></table>");
}

?>

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result
resource in
blah-blah/create_dbase.php on line 24

 

Navigation:

[Reply to this 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

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