我试图在php中动态创建mysql中的表
$usernametable="test".$usname;
$create = ("CREATE TABLE $usernametable(
id SMALLINT NOT NULL PRIMARY KEY,
test1 SMALLINT, test2 SMALLINT, test3 SMALLINT )");
$createtable = mysql_query($create, $conn)
or die ('Problem with query' . mysql_error());
它似乎没有工作,我甚至没有收到错误消息。什么似乎是问题?
答案 0 :(得分:1)
试试这个对我有用
$con = mysql_connect(<host>,<username>,<password>) or die(mysql_error());
mysql_select_db(<database_name>,$con);
$usernametable="test".$usname;
$create = ("CREATE TABLE $usernametable(
id SMALLINT NOT NULL PRIMARY KEY,
test1 SMALLINT, test2 SMALLINT, test3 SMALLINT )");
$createtable = mysql_query($create, $con)
or die ('Problem with query' . mysql_error());