Thanks Breezer. That does make sense, but I assume there must be
some database activity when a page is loaded. Also, if I use an incorrect username/password combination to log in to the manager the site behaves as expected and generates the "Incorrect username/password..." dialog. This would imply that the database has been successfully read to retrieve the credentials wouldn’t it?
Update: I’ve spoken with my host, and they suggest that because they limit the number of connections to "about 20" per site I need to ensure my code uses [tt]mysql_close();[/tt] to close any connections I make to the database. I assume that this would be happening anyway, but does anyone know of a reason why there would be a large number of connections open prior to line 85 of [tt]dbapi.mysql.class.inc.php[/tt] being called?
I believe this is the code that’s falling over:
/**
* @name: connect
*
*/
function connect($host = '', $dbase = '', $uid = '', $pwd = '', $persist = 0) {
global $modx;
$uid = $uid ? $uid : $this->config['user'];
$pwd = $pwd ? $pwd : $this->config['pass'];
$host = $host ? $host : $this->config['host'];
$dbase = $dbase ? $dbase : $this->config['dbase'];
$tstart = $modx->getMicroTime();
if (!$this->conn = ($persist ? mysql_pconnect($host, $uid, $pwd) : mysql_connect($host, $uid, $pwd, true))) {
$modx->messageQuit("Failed to create the database connection!");
exit;
} else {
$dbase = str_replace('`', '', $dbase); // remove the `` chars
if (!@ mysql_select_db($dbase)) {
$modx->messageQuit("Failed to select the database '" . $dbase . "'!");
exit;
}
$tend = $modx->getMicroTime();
$totaltime = $tend - $tstart;
if ($modx->dumpSQL) {
$modx->queryCode .= "<fieldset style='text-align:left'><legend>Database connection</legend>" . sprintf("Database connection was created in %2.4f s", $totaltime) . "</fieldset><br />";
}
$this->isConnected = true;
// FIXME (Fixed by line below):
// this->queryTime = this->queryTime + $totaltime;
$modx->queryTime += $totaltime;
}
}
Line 85 reads:
[tt]if (!$this->conn = ($persist ? mysql_pconnect($host, $uid, $pwd) : mysql_connect($host, $uid, $pwd, true))) {[/tt]
Any help in resolving this would be greatly appreciated as I’m totally stuck!