How does mysql_fetch_array block error messages without data?

Source: Internet
Author: User
How does mysql_fetch_array block data-free errors? when I connect to a database using PHP, I use mysql_fetch_array to retrieve database data.
If the table in the database has no content, an error message containing at least one element is displayed.
I want to output "no data" if there is no data, and no php error prompt will be displayed. what can I do?


Reply to discussion (solution)

error_reporting(0);$query = mysql_query($sql);mysql_fetch_array($query);........

IMPOSSIBLE. there will be no such error!

error_reporting(0);$query = mysql_query($sql);mysql_fetch_array($query);........

Error_reporting (0 );
Does this statement block all errors?


error_reporting(0);$query = mysql_query($sql);mysql_fetch_array($query);........

Error_reporting (0 );
Does this statement block all errors?

Yes. If you want to block a single error, write it like this.
@mysql_fetch_array($query);

You 'd better paste the code. example:

$ Row = mysql_fetch_array ($ result)
If (! $ Row ){
Exit ("no data ");
}

No!
If mysql_fetch_array reports an error, the input parameter must not be a mysql retsult resource.
This error indicates that an error occurred in the previous mysql_query query, which is unblocked!

$ Rs = mysql_query ('select * from tbl_name where 1 = 0'); // This must be print_r (mysql_fetch_array ($ rs) that cannot be found )); // only the empty array is printed, and no error is reported.


If (mysql_num_rows ($ rs) = 0)

Add the @ symbol to block the error message.

Thank you. @ And error_reporting (0 );

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.