Home >php教程 >php手册 >php 提示Warning: mysql

php 提示Warning: mysql

WBOY
WBOYOriginal
2016-06-06 19:43:561113browse

我的高度代码如下 include("conn.php"); if(!empty($_GET['id'])){ $sql="select * from news where `id`='".$_GET['id']."'"; $query=mysql_query($sql); $rs = mysql_fetch_array($query); } 提示错误了 Warning: mysql_fetch_array() expects parameter 1

我的高度代码如下

include("conn.php");

if(!empty($_GET['id'])){
         $sql="select * from news where `id`='".$_GET['id']."'";
         $query=mysql_query($sql);
         $rs = mysql_fetch_array($query);     
}

提示错误了

Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in F:xmappwww.111cn.netmylibrarysearch_result.php on line 32

后来我对代码进行升级

if(!empty($_GET['id'])){
         $sql="select * from news where `id`='".$_GET['id']."'";
         $query=mysql_query($sql);
if( mysql_num_rows( $query )
{
         $rs = mysql_fetch_array($query);  
}
else
{
mysql_error();
}  
}

这样就会看到mysql错误信息了,结果是sql语句有问题了,把sql语句进行修改就可以了,

http://www.111cn.net/phper/php.html

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