我尝试将旧的 php sql 脚本转换为 PDO,但它一直将用户点设置为 0 而不是添加 +15
这里是原文
<?php
session_start();
$db = mysqli_connect("host", "username", "password", "dbname");
$username = $_SESSION['username'];
mysqli_query($db, "UPDATE login_users SET Points=Points+15 WHERE username='$username'");
?>
这是我尝试创建的 PDO 语句。我的语法错了吗?
<?php
session_start();
$db = new PDO('mysql:host;dbname=dbname;charset=UTF-8', 'username', 'password');
$username = $_SESSION['username'];
$Points = $db->exec("UPDATE login_users SET Points='Points+15' WHERE username='$username'");
?>