第5行的SQL查询中出现意外的T_VARIABLE 如何解决这个问题?
<?php
include "system.php";
$usersystem = $_SESSION['username'];
$passw = $_SESSION['password'];
$query= "SELECT * FROM users WHERE username = "$usersystem" AND password = "$passw";
$autoexec= $mysqli->query($query);
$earnings = $autoexec['earnings'];
$completed = $autoexec['completed'];
if ($_SESSION['loggedin'] !=1){
header ('Location: index.php);
}
?>
答案 0 :(得分:1)
语法高亮显示使您的问题显而易见:引号。您需要在查询中为字符串使用单引号:
$query= "SELECT * FROM users WHERE username = '$usersystem' AND password = '$passw'";
答案 1 :(得分:0)
基本PHP语法:
$query= "SELECT * FROM users WHERE username = "$usersystem" AND pas
^-- ^---
您不能使用与用于分隔字符串相同类型的引号。尝试
$query= "SELECT * FROM users WHERE username = \"$usersystem\" AND pas
^--- ^--- note the escapes
由于这是一个简单的错字类型问题,投票结束这个问题......