php 提示Warning: mysql_fetch_array() expects_PHP教程
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.bKjia.c0mmylibrarysearch_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语句进行修改就可以了,
一聚教程小编提示你,导致这类错误是我们语法不规范了,如果要处理只有对sql进行一条条输出处理或在mysql_query(sql) or die(mysql_error()) 这样来处理 本站原创转载必须注明来源http://www.bKjia.c0m/phper/php.html
推荐阅读
-
Laravel访问出错提示:`Warning: require(/vendor/autoload.php): failed to open stream: No such file or di解决方法
-
Laravel访问出错提示:`Warning: require(/vendor/autoload.php): failed to open stream: No such file or di解决方法
-
PHP提示Warning:phpinfo() has been disabled函数禁用的解决方法
-
php提示Warning:mysql_fetch_array() expects的解决方法
-
php下foreach提示Warning:Invalid argument supplied for foreach()的解决方法
-
[视频教程] 配置vscode的PHP自动补全提示与使用Xdebug进行远程调试debug
-
phpmyadmin安装时提示:Warning: require_once(./libraries/common.inc.php)错误解决办法
-
PHP Warning: date(): It is not safe to rely on the system_PHP教程
-
preg_match正则匹配提示pcre.backtrack_limit解决办法_PHP教程
-
PHP中显示出错提示方法介绍_PHP教程