gpt4 book ai didi

php - 错误! : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version

转载 作者:行者123 更新时间:2023-11-29 19:44:26 24 4
gpt4 key购买 nike

我正在尝试创建一个注册表单,用户将其用户名和密码放入两个不同的文本框中,单击按钮,它会存储用户并将文本框传递到我的数据库中。

我目前收到此错误(已更新):

Error!: Cannot add or update a child row: a foreign key constraint fails (ctollins_TRTdesign.USER, CONSTRAINT fk_USER_custID FOREIGN KEY (custID) REFERENCES CUSTOMER (custID) ON DELETE CASCADE ON UPDATE CASCADE)

$con = mysql_connect('localhost','ctollins1','Apples11');
$db = mysql_select_db('ctollins_TRTdesign', $con);


$sql="INSERT INTO USER (userName, userPassword)
VALUES
('$_POST[uname]','$_POST[pass]')";

if (!mysql_query($sql,$con))
{
die('Error!: ' . mysql_error());
}
echo "1 new client added";

mysql_close($con)

最佳答案

而不是使用

INSERT INTO USER ($userName, $pass)......

在你的代码中。请使用您存储用户名和密码的列名称。我的意思是表列名称如下。

INSERT INTO USER (column-name-for-username-from db-table, column-name-for-password-from db-table).........

关于php - 错误! : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41132765/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com