php 向数据库插入数据

lemon03055003 2009-06-22 04:43:50
为什么插入数据后,数据库里面只显示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!!!";
}
...全文
115 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
lemon03055003 2009-06-22
  • 打赏
  • 举报
回复
谢谢 ,按照你的方法已经解决了
这真是个好地方
以后经常来
呵呵
lgzxz999 2009-06-22
  • 打赏
  • 举报
回复
... 外面有,没看到,嘿嘿嘿嘿,POST传值问题
lgzxz999 2009-06-22
  • 打赏
  • 举报
回复
$sql = "INSERT INTO employees (first,last,adress,position) VALUES('$first','$last','$adress','$position')";
''下面$变量是不起作用的
tfxg 2009-06-22
  • 打赏
  • 举报
回复
猜你是通過頁面傳值進來,那樣應該改成
$sql = "INSERT INTO employees (first,last,adress,position) VALUES('".$_POST[first]."','".$_POST[last]."','".$_POST[adress]."','".$_POST[position]."')";
tfxg 2009-06-22
  • 打赏
  • 举报
回复
$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了

21,891

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧