|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2002-02-06 21:04 UTC] thorr at asenacorp dot com
We moved our server from FreeBSD/PHP 4.0.6/Apache 1.3.20 to Debian/PHP 4.1.1/Apache 1.3.22. Now we are occasionally receiving the following warning for mysql_num_rows:
PHP Warning: 6 is not a valid MySQL result resource in /usr/local/webhosts/default/test.php on line 40
sometimes number 6 changes to 25, 38 etc. I could not figure out under which conditions it happens as most of the time when page is refreshed it disappears. It happens on many pages and probability of having warning increases as number of queries in the page increases. When that warning received there are no other errors or warnings. Also there is no result assosciated for the recordset that mysql_num_rows using although there should be and other recordsets are working fine.
I tried to reproduce the error with the following script and I managed to get a bunch of them. Approximately I got 9 warnings for 100 execution of the script. All executions are identical and warnings seemed to happen randomly.
Here is the script that I used for testing. The query returns 3 rows normally:
<?
$dbHost = "192.168.10.12";
$dbUser = "phpuser";
$dbPass = "passwd";
$dbName = "sb";
//Server Connection
if(!($dbLink = mysql_pconnect($dbHost,$dbUser,$dbPass)))
{
print("Failed to connect to database!<BR>\n");
exit();
}
//select database
if(!mysql_select_db($dbName,$dbLink))
{
print("Can't use database!<BR>\n");
exit();
}
for($i=0;$i<20;$i++)
{
$qryCompare = "SELECT * FROM sb_Compare WHERE constant = 11 AND variant = 10;";
if(!($recCompare=mysql_query($qryCompare, $dbLink)))
{
print("Query error!...<BR>\n");
print("MySQL say : " . mysql_error() . "<BR>\n");
print("Query was : $qryCompare<BR>\n");
exit();
}
$qryCompar = "SELECT * FROM sb_Compare WHERE constant = 11 AND variant = 10;";
if(!($recCompar=mysql_query($qryCompar, $dbLink)))
{
print("Query error!...<BR>\n");
print("MySQL say : " . mysql_error() . "<BR>\n");
print("Query was : $qryCompar<BR>\n");
exit();
}
echo mysql_num_rows($recCompare);
echo mysql_num_rows($recCompar);
}
?>
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Nov 05 09:00:01 2025 UTC |
My hitch is that you're running out of mysql connections for some reason... add this and check it: mysql_connect() or die ("error"); of course use the normal mysql_connect function (with all parameters). Derick