How to create a table from PHP?
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.php archive

How to create a table from PHP?

From: mh <marchenri1@gmail.com>
Date: Sun Jul 17 2005 - 18:42:34 CEST

Hello,

I'm trying to create a table from a PHP script.
>>From what I read in my book about PHP and MySQL I
should do something like that:

$sql_query="CREATE TABLE '$num' (
               'variable1' mediumint(6) unsigned NOT
NULL,

               'variable2' smallint(6) unsigned NOT NULL,
               PRIMARY KEY(numero),
               )";
First I tried without the 'primary key' and the '' for
the names of the variables. My script was not creating
the table so I decided to add the '' and the "primary
key". It was still not working. Then I've found that
this is working:

$sql_query = 'CREATE TABLE $num ('
        . ' `variable1` DATE NOT NULL'
        . ' )';

I'd like to know why my first test was not working
(cause it is similar to a listing in a book) and if I
really need (it's related) to use the '.' between each
line of my command?

Another problem is that the table is created with the
name $num and is not replaced like I want by its
value. How can I solve this other problem?

Thanks a lot for your help.
Received on Mon Oct 24 02:08:46 2005