为什么插入数据后,数据库里面只显示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!!!";
}

解决方案 »

  1.   

    $sql = "INSERT INTO employees (first,last,adress,position) VALUES('$first','$last','$adress','$position')"; 
    $first,$last,$adress,$position,按你上面的代碼,這幾個變量沒有賦值,你的SQL語句相當於
    $sql = "INSERT INTO employees (first,last,adress,position) VALUES('','','','')"; 
    那樣自然是只有ID了
      

  2.   

    猜你是通過頁面傳值進來,那樣應該改成
    $sql = "INSERT INTO employees (first,last,adress,position) VALUES('".$_POST[first]."','".$_POST[last]."','".$_POST[adress]."','".$_POST[position]."')"; 
      

  3.   

    $sql = "INSERT INTO employees (first,last,adress,position) VALUES('$first','$last','$adress','$position')"; 
    ''下面$变量是不起作用的
      

  4.   

    ...  外面有,没看到,嘿嘿嘿嘿,POST传值问题