gpt4 book ai didi

php - 使用变量的 SQL 更新查询

转载 作者:行者123 更新时间:2023-11-29 11:25:31 25 4
gpt4 key购买 nike

我正在编写 php 来更新用户的余额,但我的 UPDATE 查询在执行时似乎抛出错误。

    $student = $database->quote($_POST ["studentID"]);
$amount = $database->quote($_POST ["update_balance"]);

//sets query to update user balance
$query = "UPDATE `User` SET `balance`= (`.$amount.`) WHERE `userID`= (`.$student.`)";
//excecutes the query
$database->exec($query);

“studentID”和“update_balance”是 HTML 中捕获的输入字段的名称。

最佳答案

删除 (`.things. 并运行 sql 查询

$query = "UPDATE `User` SET `balance`= '$amount' WHERE `userID`= '$student'";

关于php - 使用变量的 SQL 更新查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38290685/

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