PHP expects parameter 1 to be resource, array given error _php tutorial

Source: Internet
Author: User
If you are using a class that is well-encapsulated
For example
function Fetch_array ($query, $result _type = Mysql_assoc) {
Return mysql_fetch_array ($query, $result _type);
}
[/code]
will report this error
This is supposed to be, you pass the $query is a Boolean value, and the parameters inside the Mysql_fetch_array need is the resource type, this is, your program will determine that you pass the parameter error,
We can
Copy CodeThe code is as follows:
function Fetch_array ($query, $result _type = Mysql_assoc) {
Return @mysql_fetch_array ($query, $result _type);
}

Use @ in front to suppress the error prompt, or
Try the interpretation statement to execute the statement,
Copy CodeThe code is as follows:
if (this parameter)
{
Perform
}

http://www.bkjia.com/PHPjc/323052.html www.bkjia.com true http://www.bkjia.com/PHPjc/323052.html techarticle If 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 the error this ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.