2016-03-06 47 views
-1

11行是while ($row = mysqli_fetch_array($select_user_profile_query)) {Mysqli_fetch_array()布爾誤差

警告:mysqli_fetch_array()預計參數1被mysqli_result,在C中給出布爾:\ XAMPP \ htdocs中\仁達\管理員\ profile.php第11行

if(isset($_SESSION['username'])) { 

    $username = $_SESSION['username']; 

    $query = "SELECT * users WHERE username ='{$username}' "; 
    $select_user_profile_query = mysqli_query($connection, $query); 

    while ($row = mysqli_fetch_array($select_user_profile_query)) { 

$user_id = $row['user_id']; 
$username = $row['username']; 
$user_password = $row['user_password']; 
$user_firstname = $row['user_firstname']; 
$user_lastname = $row['user_lastname']; 
$user_email = $row['user_email']; 
$user_image = $row['user_image']; 
$user_role = $row['user_role']; 



} 
} 

謝謝!

+1

你缺少了'from'在SQL – RamRaider

+1

始終使用mysqli_error(在此之前,查詢成功)到獲取查詢錯誤。 –

回答

-1

SQL語句缺少from,也許應該測試試圖通過記錄遍歷

<?php 
    if(isset($_SESSION['username'])) { 
     $username = $_SESSION['username']; 

     $query = "SELECT * from `users` WHERE `username` ='{$username}' "; 
     $select_user_profile_query = mysqli_query($connection, $query); 
     if($select_user_profile_query) { 
      while ($row = mysqli_fetch_array($select_user_profile_query)) { 
       $user_id = $row['user_id']; 
       $username = $row['username']; 
       $user_password = $row['user_password']; 
       $user_firstname = $row['user_firstname']; 
       $user_lastname = $row['user_lastname']; 
       $user_email = $row['user_email']; 
       $user_image = $row['user_image']; 
       $user_role = $row['user_role']; 
      } 
     } 
    } 
?> 
相關問題