mysql 聯集查詢在資料庫裡測試時正確,通過php操作就不對了?

來源:互聯網
上載者:User
關鍵字 mysql php
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 前面沒空格。

大神就是大神~~~樓上正解,想評論來著,搞錯地方了

  • 相關文章

    聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.