php 提示Warning: mysql_fetch_array() expects
发布:smiling 来源: PHP粉丝网 添加日期:2014-01-09 13:46:16 浏览: 评论:0
在mysql数据库连接时碰到Warning: mysql_fetch_array() expects ...错误提示,根据我的经验这个是sql返回的query为空了,我们没有加己判断直接使用了mysql_fetch_array()函数导致的下面我们一起来看问题解决方案。
实例代码如下:
- include("conn.php");
- if(!emptyempty($_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.phpfensi.commylibrarysearch_result.php on line 32
对代码进行修改,如下:
- if(!emptyempty($_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()) 这样来处理.
Tags: Warning: mysqlfetcharray
相关文章
- ·Warning: mysql_fetch_array():(2013-11-28)
- ·Warning: Missing argument 3 for photo_bigclass()(2013-11-28)
- ·Warning: mssql_connect() [function.mssql-connect]:(2013-11-28)
- ·Warning: mysql_fetch_assoc() expects parameter 1 to be resource(2013-12-02)
- ·Warning: mysql_num_rows():(2014-01-14)
- ·Warning:chmod() has been disabled for security reasons in(2014-08-23)
- ·php提示 Warning: touch() [function.touch]: Utime failed: Permission denied in(2014-09-20)
- ·php提示Warning: file_get_contents(): couldn’t resolve(2014-09-20)
- ·PHP Warning:phpinfo() has been disabled函数禁用(2014-09-21)
- ·php 提示Warning: mysql_fetch_array() expects(2014-09-21)
- ·php下foreach()错误提示Warning: Invalid argument supplied for foreach()(2014-09-22)
- ·phpmyamdin安装出现Warning: require(./libraries/Error_Handler.class.php) 错(2015-04-04)
- ·PHP Warning: implode() [function.implode]: Invalid(2015-04-08)
- ·php下foreach提示Warning:Invalid argument supplied for foreach()的解决方法(2021-04-25)
- ·php提示Warning:mysql_fetch_array() expects的解决方法(2021-05-03)
- ·PHP Warning: Module 'modulename' already loaded in问题解决办法(2021-05-16)
推荐文章
热门文章
最新评论文章
- 写给考虑创业的年轻程序员(10)
- PHP新手上路(一)(7)
- 惹恼程序员的十件事(5)
- PHP邮件发送例子,已测试成功(5)
- 致初学者:PHP比ASP优秀的七个理由(4)
- PHP会被淘汰吗?(4)
- PHP新手上路(四)(4)
- 如何去学习PHP?(2)
- 简单入门级php分页代码(2)
- php中邮箱email 电话等格式的验证(2)