我正在尝试创建一个包含用户引入的变量的表。如果我“回显”最终变量,它表明该行是正确的,但我仍然无法创建它。有人能帮助我吗?
<?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();
?>
答案 0 :(得分:2)
在第一个“VARCHAR(20)
之前,您需要一个空格