简体   繁体   中英

Mysql query fails sometimes not always

I have a simple mysql query in a PHP page. The query is somehow like this-

$q=mysql_query("SELECT * FROM ip_tables");  
echo mysql_num_rows($q);  

The number of rows in ip_tables is simply 5-10 . The problem is this simple query fails sometimes without any reason. For example, sometimes I load the page and find the error message Warning: invalid argument supplied to mysql_num_rows. resource required, boolean given in ... Warning: invalid argument supplied to mysql_num_rows. resource required, boolean given in ... .

But at that moment if I refresh the page, the error does not occur and it shows the correct row number. This problem occurs sometimes not always. Anyone have a solution for this?

Thanks

这将在您的错误日志文件中记录mysql错误:mysql_query(“ SELECT * FROM ip_tables”)或error_log(mysql_error());

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM