DB not connecting - but will on refresh! HELP!
Posted: Mon Jun 16, 2003 7:14 pm
This is driving me nuts!
Everything has been working fine, but now I notice when I hit a page for the first time on this site I am working on I get a unable to conenct to database message. I refresh the page, and everything comes up and on all following pages.
It has something to do with my sessions because when I take out the session information it works fine.
here is my code. This is in a file called db.php and included at the top of all the pages:
In this order, the $dbloc - $dbuser, etc don't even register (included in error messge and didn't show).
If I add the session register information after the sql, does not create a session_id.
Any Advice???? (PS: This does not have anything to do with the previous post about speeding up query.)
Thanks,
Tim
Everything has been working fine, but now I notice when I hit a page for the first time on this site I am working on I get a unable to conenct to database message. I refresh the page, and everything comes up and on all following pages.
It has something to do with my sessions because when I take out the session information it works fine.
here is my code. This is in a file called db.php and included at the top of all the pages:
Code: Select all
session_start ();
if(empty($session_id)) {
$cust_ip = "$REMOTE_ADDR";
session_register("cust_ip" );
$xxid2 = str_replace(".", "", $cust_ip);
$session_id = (date("ymdHis" ) . "$xxid2" );
session_register("session_id" );
$cust_refer = $HTTP_REFERER;
session_register("cust_refer" );
}
$dbloc = "localhost";
$dbuser = "XXXXX";
$dbpass = "XXXXXX";
$dbname = "XXXXXX";
$dbcon = @mysql_connect("$dbloc", "$dbuser", "$dbpass" );
if (!$dbcon) {
echo( "Unable to connect to the database" );
exit();
}
if (! @mysql_select_db("$dbname", $dbcon) ) {
echo( "Unable to locate the $dbname database " );
exit();
}In this order, the $dbloc - $dbuser, etc don't even register (included in error messge and didn't show).
If I add the session register information after the sql, does not create a session_id.
Any Advice???? (PS: This does not have anything to do with the previous post about speeding up query.)
Thanks,
Tim