gpt4 book ai didi

MySQL 更新未设置新标志

转载 作者:行者123 更新时间:2023-11-29 23:40:56 24 4
gpt4 key购买 nike

我不知道为什么,但更新不起作用,知道吗?在正常情况下,它应该检查代码输入是否有效(代码),然后将代码 var $name 的行“used”设置为 1

<?php
$hostname = "localhost";
$username = "xxx";
$dbname = "xxx";
$password = "xxx";
$usertable = "codes";
$yourfield = "code";
$connection = mysql_connect($hostname, $username, $password) OR DIE ("Unable to
connect to database! Please try again later.");
mysql_select_db($dbname);



$query = "SELECT * FROM $usertable WHERE $yourfield = '" . $_GET["code"] . "' AND used = 0";
$result = mysql_query($query);
$rowSelected = mysql_num_rows($result);
if ($rowSelected ) {
while($row = mysql_fetch_array($result)) {
$name = $row["$yourfield"];
$wert = $row["wert"];
echo "Code valid<br>";
echo "Code: $name<br>";
echo "Value: $wert";
$mysql_query($connection, 'UPDATE codes SET used=1 WHERE code="$name"');

}


}
else {
echo "Code invalid!";
}
mysql_close($connect);
?>

最佳答案

你的引用有误

'UPDATE codes SET used=1 WHERE code="$name"'

他们应该是

"UPDATE codes SET used=1 WHERE code='$name'"

关于MySQL 更新未设置新标志,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26161982/

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