Home  >  Article  >  Backend Development  >  关于查询,但是语句和连接肯定没有关问题

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

WBOY
WBOYOriginal
2016-06-13 13:37:02702browse

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

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打印出来
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn