MySQL Tables

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
icesolid
Forum Regular
Posts: 502
Joined: Mon May 06, 2002 9:36 pm
Location: Buffalo, NY

MySQL Tables

Post by icesolid »

How to I create MySQL tables trough PHP. I am looking for a command here, not a way of running a text file with the information. That I know how to. I was looking for a PHP command to do this.
qads
DevNet Resident
Posts: 1199
Joined: Tue Apr 23, 2002 10:02 am
Location: Brisbane

Post by qads »

Code: Select all

mysql_create_table('tablename');
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Unfortunately, mysql_create_table() doesn't exist (mysql_create_db() does although it is deprecated) instead you need to run an SQL statement containing the information required to create a table. Once you're connected to the database you could do something like:

Code: Select all

$sql = "CREATE TABLE test (blob_col BLOB, INDEX(blob_col(10)))";
mysql_query($sql) or die(mysql_error());
Basically you would just use the SQL CREATE TABLE statement.

Mac
Post Reply