Home  >  Article  >  Backend Development  >  php expects parameter 1 to be resource, array given error_PHP Tutorial

php expects parameter 1 to be resource, array given error_PHP Tutorial

WBOY
WBOYOriginal
2016-07-21 15:31:26840browse

If you are using a packaged class
for example
function fetch_array($query, $result_type = MYSQL_ASSOC) {
return mysql_fetch_array($query, $result_type);
}
[/ code]
This error will be reported
This is because the $query you pass is a Boolean value, and the parameters in mysql_fetch_array require resource types. This is because your program will determine that the parameters you pass are wrong. ,
We can

Copy code The code is as follows:

function fetch_array($query, $result_type = MYSQL_ASSOC) {
return @mysql_fetch_array($query, $result_type);
}

Use @ in front to suppress error prompts, or
try the interpretation statement to execute this statement,
Copy code The code is as follows:

if (this parameter)
{
Execute
}

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/323052.htmlTechArticleIf you are using a packaged class such as function fetch_array($query, $result_type = MYSQL_ASSOC) { return mysql_fetch_array ($query, $result_type); } [/code] will report this error...
Statement:
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