Greetings,
I have a problem which shows up *intermittently* when executing a
simple query. Basically, mysql_query() returns no resource *some* of
the time. When I trap the error using mysql_error(), I get the
following:
"No Database Selected"For kicks, I altered the query to use the fully qualified table name
(<db>.<table>), and the error changed to:
"Access denied for user: '[EMAIL PROTECTED]' to database 'db'"If I continue after the error, this is followed by:
"PHP Warning: mysql_num_rows(): supplied argument is not a
valid MySQL result resource in /home/www/..."I was able to replicate this on a browser as well as using "ab" with no concurrency. The system will sometimes handle 1000 or more queries without any problems, and then a bunch of errors will appear.
I cannot roll this out into a production environment until this is fixed. I would really appreciate any advice.
Here's the relevant code:
$conn = mysql_connect(CHAR_DB,CHAR_DB_USER,CHAR_DB_PASS) or die("Cannot connect to db.");
mysql_select_db(USER_DB, $conn);
$sql = "SELECT cash FROM cash WHERE id = '$id'";
$res = mysql_query($sql);
if (!$res) {
error_log('Invalid query: ' . mysql_error());
}$numrows = mysql_num_rows($res);
Thanks!
-- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
