为什么插入数据后,数据库里面只显示id(我设置的是auto_increment),插入的内容无法显示
但是程序没有显示错误
这是为什么呢?
if($_POST['submit'])
{
$db = mysql_connect("localhost","root");
mysql_select_db("xuesheng",$db);
var_dump($_POST['first']);
$sql = "INSERT INTO employees (first,last,adress,position) VALUES('$first','$last','$adress','$position')";
$result = mysql_query($sql);
echo "input sucess!!!";
}
但是程序没有显示错误
这是为什么呢?
if($_POST['submit'])
{
$db = mysql_connect("localhost","root");
mysql_select_db("xuesheng",$db);
var_dump($_POST['first']);
$sql = "INSERT INTO employees (first,last,adress,position) VALUES('$first','$last','$adress','$position')";
$result = mysql_query($sql);
echo "input sucess!!!";
}
$first,$last,$adress,$position,按你上面的代碼,這幾個變量沒有賦值,你的SQL語句相當於
$sql = "INSERT INTO employees (first,last,adress,position) VALUES('','','','')";
那樣自然是只有ID了
$sql = "INSERT INTO employees (first,last,adress,position) VALUES('".$_POST[first]."','".$_POST[last]."','".$_POST[adress]."','".$_POST[position]."')";
''下面$变量是不起作用的