doujing5726 2013-04-10 22:38 采纳率: 0%
浏览 12

为什么我的php文件不会将数据插入我的mysql数据库?

I have been having trouble getting my PHP file to insert data into my database. I have gone so far as making one simple script to put data into my database and it still isn't working. I'm hoping that someone will see something that will make me feel like a dork for having missed it. The code below is what is in my simple script that isn't inserting into my database.

<? php
$con=mysql_connect("localhost","user","password","database"

mysql_query($con,"INSERT INTO table_name (username, pass) VALUES ('bob', 'tom')");

mysql_close($con);

?>

I hope that you guys see the problem because I'm drawing a complete blank.

  • 写回答

3条回答 默认 最新

  • duanqin7791 2013-04-10 22:40
    关注

    You're missing mysql_select_db("yourdatabase", $con);

    Edit: forget that, you have it in your connection, but like someone commented, you have a syntax error.

    You can also use mysql_error() to see what's going wrong.

    P.s. the use of the old mysql extension is highly discouraged.

    评论

报告相同问题?

悬赏问题

  • ¥15 mmocr的训练错误,结果全为0
  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀