所以,我有这段代码应该更新数据库中的值,但是它不起作用,有人可以帮助我找出原因吗?$bitcoin = $_POST['bitcoin']; $dsn = 'mysql:host=127.0.0.1;dbname=user_db;charset=utf8'; $conn = new PDO($dsn, $username1, $password); $conn->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $stmt= $conn->prepare("UPDATE users SET bitcoin = :bitcoin WHERE username = :username"); $stmt->bindParam(':bitcoin', $bitcoin,PDO::PARAM_STR); $stmt->bindParam(':username', $username,PDO::PARAM_STR); $stmt->execute(); $try = $conn->fetch(PDO::FETCH_ASSOC); if ($try) { array_push($success, "Bitcoin Wallet Adress updated successfully."); } else { array_push($errors, "Error updating Bitcoin Wallet Adress, please report this error to us."); } header('location: settings.php'); $conn->close();```
1 回答
猛跑小猪
TA贡献1858条经验 获得超8个赞
也许改变
$try = $conn->fetch(PDO::FETCH_ASSOC);
至
$try = $conn->rowCount();
是否检测更新记录。
- 1 回答
- 0 关注
- 197 浏览
添加回答
举报
0/150
提交
取消