遇到一些代码和字符串处理问题
语法错误,意外的文件结束......
有人可以帮忙吗?
<?php
require("common.php");
if(empty($_SESSION['user']))
{
header("Location: login.php");
die("Redirecting to login.php");
}
$query = "
SELECT
id,
username,
email,
gold
FROM users
";
try
{
$stmt = $db->prepare($query);
$stmt->execute();
}
catch(PDOException $ex)
{
die("Failed to run query: " . $ex->getMessage());
}
$rows = $stmt->fetchAll();
mysqli_query($con,"UPDATE users SET gold = gold + 10
WHERE username= '".$_SESSION['user']['username']."');
header('Location: quests.php');
die();
?>
答案 0 :(得分:1)
您忘了关闭引用的字符串:
mysqli_query($con,"UPDATE users SET gold = gold + 10
WHERE username= '".$_SESSION['user']['username']."'");
答案 1 :(得分:0)
mysqli_query($con,"UPDATE users SET gold = gold + 10 WHERE username= '".$_SESSION['user']['username']."');
您忘记关闭引用"
应该是这样的:
mysqli_query($con,"UPDATE users SET gold = gold + 10 WHERE username= '".$_SESSION['user']['username']."'");
答案 2 :(得分:0)
您错过了"
行的结束mysqli_query
:
."');
需要
."'");
如果你的编辑器没有使用语法高亮显示这一点,你应该使用不同的编辑器。
答案 3 :(得分:0)
而不是
mysqli_query($con,"UPDATE users SET gold = gold + 10
WHERE username= '".$_SESSION['user']['username']."');
使用
mysqli_query($con,"UPDATE users SET gold = gold + 10
WHERE username= '".$_SESSION['user']['username']."'");