November 11th, 2000, 10:21 AM
Is it possible to create a table through PHP? ie not by Telnet or phpMyAdmin?
If so, could someone post a small example?
November 11th, 2000, 11:04 AM
You can send ANY mysql query via the mysql_query() function.
mysql_query("create table foo.....");
You can use any query just as you'd use it on the command line except you have to escape double quotes.
November 11th, 2000, 05:50 PM
So, am I right to assume that the following would work?
mysql_connect (localhost, username, password);
$sql = "CREATE TABLE test(username CHAR(10) NOT NULL, password CHAR(60) NOT NULL, PRIMARY KEY(ID))";
$result = mysql_query($sql);
[This message has been edited by AoErat (edited November 11, 2000).]
November 11th, 2000, 07:05 PM
No, it wouldn't.....
ID is not defined so you can't make it your primary key.
Other than that it'll work fine.
November 11th, 2000, 10:18 PM
Thanks a lot!