我正在尝试为特定用户更新 bio 列,但我得到了一个新行。经历过类似的问题,但无法解决我的情况。
if (isset($_SESSION['logged_in']) && $_SESSION['name_of_user'] == $profile_name) {
$pageOwner = true;
}
if (isset($_POST['submit'])) {
$bio = $_POST['bio'];
if (empty($bio)) {
$error = "Missing Bio";
} else {
if ($member_bio->num_rows == 1) {
if ($query = $db->query("UPDATE user_account SET 'bio'='$bio' WHERE 'id_user'='$id'")) {
$ok_mesg = "Profile has been updated!!!";
} else {
$error = "ERROR on our end";
}
} else {
if ($query = $db->query("INSERT INTO user_account (bio) VALUES('$bio')")) {
$ok_msg = "Profile has been updated";
} else {
$error = "Error on our end";
}
}
}
}