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 );