Re: Ghost in my machine?

From: Date: Thu, 22 May 2003 13:00:59 +0000
Subject: Re: Ghost in my machine?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-148552@lists.php.net to get a copy of this message
Can you give us the actual portion of code a bit before and bit after the problem <daniel@rhesusb.dk> wrote in message news:004e01c3205f$df1f7ab0$de01a8c0@Asus... Hi all! I'm totally stomped here... I'm making a backend, and have an include script that connects to the database using session vars. It first checks for the presence of $dbUser and $dbPassword in the session vars, then establishes a connection to MySQL using the data herein. If everything goes well, a control variable, $dbConnected, is set to TRUE. The script finally controls that value like this: if(!$dbConnected) { // HTML output to request username and password } Now, the weird thing is, it seems the very testing of the $dbConnected variable actually resets it. If I do an echo($dbConnected) before testing it, I get a TRUE (1), but if I do the same echo after testing if it's false, I don't. The if(!$dbConnected) statement always returns true, even if $dbConnected is true. Like this: echo("dbConnected variable is $dbConnected"); if(!$dbConnected) { echo("dbConnected variable is $dbConnected); } - when loading the page, I get dbConnected variable is 1 dbConnected variable is I also tried testing with... if($dbConnected != TRUE) ...but to no avail. Now, if I do something silly, like this... echo("dbConnected variable is $dbConnected"); if($whatTheHell != 10000029423894) { echo("dbConnected variable is $dbConnected); } ...then I get: dbConnected variable is 1 dbConnected variable is 1 So this leads me to the conclusion that it's the if statement that's throwing away my value. But why? Is it because I'm using session vars? I've checked the actual connection, and pulled data from the database successfully, so $dbConnected is correct to return TRUE in the first place... As said, I'm stomped =( Please help. Thanks, Daniel

« previous php.general (#148552) next »