gpt4 book ai didi

php - SQL 更新显示成功,但未更新数据库中的表

转载 作者:行者123 更新时间:2023-11-30 01:12:14 25 4
gpt4 key购买 nike

我的 SQL 更新查询出现问题,它显示成功,但实际上并未更新数据库记录。

<?php

require_once('auth.php');

$host="localhost"; // Host name
$username="root"; // Mysql username
$password="sysadmin"; // Mysql password
$db_name="Elite"; // Database name
$tbl_name="Triage"; // Table name

mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");

$sql="UPDATE Triage SET directly='$directly', psychologically='$psychologically' WHERE Reference='$Reference'";
$result=mysql_query($sql);

最佳答案

$sql="UPDATE Triage SET directly='$directly', psychologically='$psychologically' WHERE Reference='$Reference'";

上面的代码中没有定义该查询中使用的变量。 $directly、$psychologically、$Reference:没有任何值(value)。为它们定义值即可。

$Reference 是必须的,即使其他人不是。

关于php - SQL 更新显示成功,但未更新数据库中的表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19380875/

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