Re: Classes and Functions and If's (Problems Again)

From: Date: Thu, 03 Nov 2005 23:42:38 +0000
Subject: Re: Classes and Functions and If's (Problems Again)
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-225075@lists.php.net to get a copy of this message
On Thu, 2005-11-03 at 18:37 -0500, Unknown Unknown wrote: > Hi everyone, i have some code that proccesses a login form. i have an object > $DB which works only in SOME areas, this is the code: > > <?php > require_once("Include.php"); > global $DB; There is no need to global $DB here. You are already in the global scope. > $Username= $_REQUEST['Username']; > $Password= $_REQUEST['Password']; > $SQL=" SELECT * FROM members WHERE Username='$Username' AND > Password='$Password'; "; > $DB->Query($SQL); > $UserInfo=$DB->QueryInfo("Array"); > if($UserInfo==0) $Login="FALSE"; > else $Login="TRUE"; Why aren't you using real boolean values here? > //Make Sure the user is not a duplicate user trying to log in again > if($Login="TRUE") > { > global $DB; Again, no need to global $DB. You are still in the global scope. > $RL="__"; > $LoginD="__"; > $ID=$UserInfo['ID']; > echo $ID; > $DB="membersp"; Here is your problem. You just replaced the $DB object with a string. Maybe you meant to set a property on the $DB object? I think you may need to do some reading on OOP, perhaps start at http://php.net/oop for PHP4 or http://php.net/oop5 for PHP5. -- Jasper Bryant-Greene General Manager Album Limited e: jasper@album.co.nz w: http://www.album.co.nz/ b: http://jbg.name/ p: 0800 4 ALBUM (0800 425 286) or +64 21 232 3303 a: PO Box 579, Christchurch 8015, New Zealand

« previous php.general (#225075) next »