gpt4 book ai didi

PHP-更新表时出错

转载 作者:太空宇宙 更新时间:2023-11-03 10:45:35 25 4
gpt4 key购买 nike

<分区>

我正在尝试像这样更新 MySQL 表行中的一行:

$conn = new mysqli('localhost','root','','db');
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}

//if input == members
$sql = "UPDATE `members` SET id = ".$_POST['id']." fname = ".$_POST['fname'].", lname = ".
$_POST['lname'].", gender = ".$_POST['gender'].", age_group = ".$_POST['age_group'].", status = ".
$_POST['status'].", dob_day = ".$_POST['dob_day'].", dob_month = ".$_POST['dob_month'].", wed_anni_day = ".
$_POST['wed_anni_day'].", wed_anni_month = ".$_POST['wed_anni_month'].", type = ".
$_POST['type'].", email = ".$_POST['email'].", address = ".$_POST['address'].", city = ".$_POST['city'].", zipco = ".
$_POST['zipco'].", contact1 = ".$_POST['contact1'].", contact2 = ".$_POST['contact2'];

if ($conn->query($sql) === TRUE) {
echo "Record updated successfully";
} else {
echo "Error updating record: " . $conn->error;
}

我收到这个错误:

Error updating record: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'fname = s_name, lname = l_name, gender = Female, age_group = Adult, status = ' at line 1

我做错了什么?谢谢。

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