SQL語句如下:
"SELECT t.task_name,t.task_begin_p,t.task_end_p,t.task_end_r,p.proj_name from tasks as t inner join projects as p on t.task_project_id=p.proj_id where t.task_user_id=".$_SESSION['user_id']."order by t.task_begin_p ASC,t.task_end_p ASC;"
php代碼如下:
$link = mysqli_connect('localhost','root','root');$db = mysqli_select_db($link,'workon');mysqli_query($link,"set names 'utf8'"); $query = "SELECT t.task_name,t.task_begin_p,t.task_end_p,t.task_end_r,p.proj_name from tasks as t inner join projects as p on t.task_project_id=p.proj_id where t.task_user_id=".$_SESSION['user_id']."order by t.task_begin_p ASC,t.task_end_p ASC"; $data = mysqli_query($link,$query);while ($row = mysqli_fetch_assoc($data)) {};
返回錯誤如下:
Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given in
回複內容:
SQL語句如下:
"SELECT t.task_name,t.task_begin_p,t.task_end_p,t.task_end_r,p.proj_name from tasks as t inner join projects as p on t.task_project_id=p.proj_id where t.task_user_id=".$_SESSION['user_id']."order by t.task_begin_p ASC,t.task_end_p ASC;"
php代碼如下:
$link = mysqli_connect('localhost','root','root');$db = mysqli_select_db($link,'workon');mysqli_query($link,"set names 'utf8'"); $query = "SELECT t.task_name,t.task_begin_p,t.task_end_p,t.task_end_r,p.proj_name from tasks as t inner join projects as p on t.task_project_id=p.proj_id where t.task_user_id=".$_SESSION['user_id']."order by t.task_begin_p ASC,t.task_end_p ASC"; $data = mysqli_query($link,$query);while ($row = mysqli_fetch_assoc($data)) {};
返回錯誤如下:
Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given in
=".$_SESSION['user_id']."order by
這裡,看到了嗎?order by 前面沒空格。
大神就是大神~~~樓上正解,想評論來著,搞錯地方了