patl wrote:Right now my code has way too many calls to db_connect() so i'm looking for an alternative. Any thoughts are greatly appreciated. Thanks a lot.
In principle, you would want to close the db connection after using it to query it. I have just two simple funtions, one to connect, and on to disconnect, which are in the base include file for each page.
Then you just:
$DBH = db_connect();
// query
db_disconnect($DBH);
function db_connect()
{
global $db_host, $db_user, $db_password, $db_name;
$db_link = mysql_connect($db_host, $db_user, $db_password)
or handle_errors("GEN", 1, 1, -1);
mysql_select_db($db_name);
return $db_link;
}
function db_disconnect($db_link)
{
mysql_close($db_link);
}