问题与以下代码有关
if(isset($_SESSION["username"])){
$username = $_SESSION["username"];
$sql = "SELECT * FROM users WHERE username = $username";
$stmt = $connect->link->query($sql);
while($row = $stmt->fetch()){
$first = $row["first_name"];
$last = $row["last_name"];
$email = $row["email"];
$role = $row["role"];
$username = $row["username"];
$status = $row["status"];
}
}
返回以下错误
Fatal error: Uncaught Error: Call to a member function fetch() on boolean in C:\wamp64\www\cms\CMS_TEMPLATE\admin\profile.php on line 12
我只能假定问题是在sql语句中引用变量的方式吗?