MySQL数据库不想添加任何新记录

发布于 2024-08-22 14:02:30 字数 332 浏览 1 评论 0原文

好的,我有这段代码

`$sql = "INSERT INTO userTable (username, password, gender, city, zip, email) VALUES ('$username', '$password', '$male', '$city', '$email')";
mysql_query($sql) or die ("unable to process query");`

,由于某种原因,它可以在我的本地服务器上运行,但不能在网络服务器上运行,所有变量都已设置。它给了我无法处理查询错误,

我是否做了一些明显错误的事情?多谢

ok so I have this code

`$sql = "INSERT INTO userTable (username, password, gender, city, zip, email) VALUES ('$username', '$password', '$male', '$city', '$email')";
mysql_query($sql) or die ("unable to process query");`

and for some reason it works on my local server but not on the webserver, all the variables are set for sure. it gives me the unable to process query error,

am i doing something obviously wrong? thanks a lot

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

人心善变 2024-08-29 14:02:30

您提供了 6 个参数,但插入语句中只提供了 5 个值。

试试这个

$sql = "INSERT INTO userTable (用户名, 密码, 性别, 城市, 邮政编码, 电子邮件) VALUES ('$username', '$password', '$male', '$city', '$zip ', '$email')";
mysql_query($sql) or die(“无法处理查询”);

You're providing 6 parameters, but only 5 values in your insert statement.

try this

$sql = "INSERT INTO userTable (username, password, gender, city, zip, email) VALUES ('$username', '$password', '$male', '$city', '$zip', '$email')";
mysql_query($sql) or die ("unable to process query");

依 靠 2024-08-29 14:02:30

ScArcher 似乎找到了正确的答案,但您可能还想了解 mysql_error 。您可以使用它从数据库打印错误,这样下次您也许可以自己解决错误。

ScArcher seems to have found the correct answer, but you might also want to know about mysql_error. You can use this to print the error from the database, so next time you can perhaps solve the error yourself.

余厌 2024-08-29 14:02:30

缺少 $gender

$gender is missing

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文