Home > Backend Development > PHP Tutorial > mysql_fetch_array(): supplied argument is not a valid MySQL result resource

mysql_fetch_array(): supplied argument is not a valid MySQL result resource

WBOY
Release: 2016-06-23 14:21:10
Original
1393 people have browsed it

php 无效sql结果资源 mysql


nbsp;html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">



江苏农二代农林生态发展有限公司



include "conn/conn.php";

?>
?>








mysql_fetch_array(): supplied argument is not a valid MySQL result resource


  
    
      
      
      
    
  

    
      
    

    
   
      
    

   
      
    

   
      
    

   
      
    

   
      
    

   
      
    





 

        
          
          
        
      
  新闻中心 News

        
          
          
        
      
  公司新闻

        
          
          
        
      
  行业咨询

        
          
          
        
      
  技术问答

        
          
          
        
      
  成功案例

        
          
          
        
      
  客户评价

        
          
          
        
      
  公司服务
 
        
          
          
       
       
    if($_GET['identification'] != null){
$sql = mysql_query("select * from frontpagenews where identification = ".$_GET['identification']."order by createDate desc limit 0,7");
这里报错 while($result = mysql_fetch_array($sql)){  
?>




        

}
}else{

$sql = mysql_query("select * from frontpagenews where identification = 1 order by createDate desc limit 0,7");
while($result = mysql_fetch_array($sql)){
?>

          
          
          
        
}
}
   ?>
   
       
               

      

            
              
              
              
            
          
新闻中心   您现在位置:首页 > 新闻中心 
mysql_fetch_array(): supplied argument is not a valid MySQL result resource
mysql_fetch_array(): supplied argument is not a valid MySQL result resource

  




错误信息

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\Apache\htdocs\growers\news.php on line 147

回复讨论(解决方案)

$sql = mysql_query("select * from frontpagenews where identification = ".$_GET['identification']." order by createDate desc limit 0,7");

 mysql_query("select * from frontpagenews where identification = ".$_GET['identification']. "order by createDate desc limit 0,7");
除非 $_GET['identification'] 最后的字符是空格,不然 $_GET['identification'] 的值不就和 order 连在一起了?
如果 $_GET['identification'] = 1
你的 sql指令不就了
"select * from frontpagenews where identification = 1order by createDate desc limit 0,7"
吗?

粗心要人命啊。多谢了。少个空格

source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template