Home > php教程 > php手册 > php expects parameter 1 to be resource, array given 错误

php expects parameter 1 to be resource, array given 错误

WBOY
Release: 2016-06-21 08:55:05
Original
1555 people have browsed it

如果你使用的是封装好的类
例如
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(这个参数)
{
执行
}



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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template