我正在尝试使用用户引入的变量创建一个表。如果我“回显”最终变量,则表明该行是正确的,但是我仍然无法创建它。有人能帮我吗?
<?php
$ligacao=mysql_connect('localhost','root','')
or die ('Problems connecting to MySQL');
$dbname = $_POST['txt_db_name'];
$tbname = $_POST['txt_tb_name'];
$campo1 = $_POST['txt_campo1'];
$campo2 = $_POST['txt_campo2'];
$campo3 = $_POST['txt_campo3'];
$campo4 = $_POST['txt_campo4'];
$campo5 = $_POST['txt_campo5'];
$campo6 = $_POST['txt_campo6'];
$campo7 = $_POST['txt_campo7'];
mysql_select_db($dbname,$ligacao);
$query = "CREATE TABLE ".$tbname." ( id INT NOT NULL AUTO_INCREMENT, ".$campo1."VARCHAR(20) NOT NULL, ".$campo2." VARCHAR(50) NOT NULL, ".$campo3." VARCHAR(30) NOT NULL, ".$campo4." VARCHAR(30) NOT NULL, ".$campo5." VARCHAR(30) NOT NULL, ".$campo6." VARCHAR(30) NOT NULL, ".$campo7." VARCHAR(30) NOT NULL, PRIMARY KEY(id))";
echo $query;
$resultado = mysql_query($query,$ligacao);
mysql_close();
?>