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

php 提示Warning: mysql

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-06 19:43:56
Original
1118 people have browsed it

我的高度代码如下 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

Related labels:
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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template