[英]Mysql query fails sometimes not always
I have a simple mysql query in a PHP page. 我在PHP页面中有一个简单的mysql查询。 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
. ip_tables
的行数仅为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 ...
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());
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.