|
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]
|