php expects parameter 1 to be resource, array given 错误
Jun 21, 2016 am 08:55 AM如果你使用的是封装好的类
例如
function fetch_array($query, $result_type = MYSQL_ASSOC) {
return mysql_fetch_array($query, $result_type);
}
[/code]
会报这个错误
这是应为,你传递的$query是布尔值,而mysql_fetch_array 里面的参数需要的是资源类型,这是,你的程序会判定你传递的参数错误,
我们可以
复制代码 代码如下:
function fetch_array($query, $result_type = MYSQL_ASSOC) {
return @mysql_fetch_array($query, $result_type);
}
在前面使用@来禁止错误提示,或者
试用判读语句来执行这个语句,
复制代码 代码如下:
if(这个参数)
{
执行
}

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

PHP's big data structure processing skills

How to optimize MySQL query performance in PHP?

How to use MySQL backup and restore in PHP?

What are the application scenarios of Java enumeration types in databases?

How to insert data into a MySQL table using PHP?

How to fix mysql_native_password not loaded errors on MySQL 8.4

How to use MySQL stored procedures in PHP?

Performance optimization strategies for PHP array paging
