Maison  >  Article  >  développement back-end  >  关于查询,但是语句和连接肯定没有关问题

关于查询,但是语句和连接肯定没有关问题

WBOY
WBOYoriginal
2016-06-13 13:37:02702parcourir

关于查询,但是语句和连接肯定没问题

PHP code
<!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

-->
    $shop_qu="select * from phone where p_id=$id";
    mysql_select_db('htc',$conn);
    $shop_re1=mysql_query($shop_qu);
    [color=#FF0000]while ($shop_re2=mysql_fetch_row($shop_re1)){[/color]
    foreach ($shop_re2 as $va){    



报错
Warning: mysql_fetch_row() expects parameter 1 to be resource, boolean given in

  我确定连接没问题,以前调试的时候就是这样用的,
  
  但是后来修改功能的时候重写了语句 然后就报错了,
   
  我又在数据库里试了试赋值后的语句,有结果,但就是php里调用不了

------解决方案--------------------
$shop_re1 = mysql_query($shop_qu) or die("Invalid query: " . mysql_error());
试下这个
------解决方案--------------------
$id有值吗
$shop_qu="select * from phone where p_id=$id";
echo $shop_qu; //把这个$shop_qu打印出来
Déclaration:
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