mysql 联合查询在数据库里测试时正确,通过php操作就不对了?

WBOY
Libérer: 2016-06-06 20:07:52
original
1098 Les gens l'ont consulté

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代码如下:

<code>$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)) {};</code>
Copier après la connexion
Copier après la connexion

返回错误如下:
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代码如下:

<code>$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)) {};</code>
Copier après la connexion
Copier après la connexion

返回错误如下:
Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given in

=".$_SESSION['user_id']."order by 这里,看到了吗?order by 前面没空格。

大神就是大神~~~楼上正解,想评论来着,搞错地方了

Étiquettes associées:
source:php.cn
Déclaration de ce site Web
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn
Tutoriels populaires
Plus>
Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal