Re: DB Select

From: Date: Sat, 25 Nov 2000 16:34:57 +0000
Subject: Re: DB Select
References: 1  Groups: php.windows 
Request: Send a blank email to php-windows+get-4103@lists.php.net to get a copy of this message
hallo ben others, because your question wasnt answered yet, ill try. Ben wrote: > I am using the following script to select stuff from a database. > > <? > mysql_connect("$db_host", "$db_user", "$db_pass"); > $query = "SELECT * FROM users where LoginName = '$user' and Active = > 'Yes'"; > $result = mysql_db_query("$db_name", $query); > if ($result) { try an echo $result, then you will ALWAYS get an id-link identifier, in other words: $result is true for every query ! > > while ($r = mysql_fetch_array($result)) { $FullName = > $r["FullName"]; $Email = $r["Email"]; > $LoginName = $r["LoginName"]; $Password = > $r["Password"]; $Address = $r["Address"]; $Telephone = > $r["Telephoene"]; $Active = $r["Active"]; > > echo " > $LoginName<BR>$Active > "; } > } as mentionend above: this else will never work! > else { echo "Account Not Active"; } > mysql_free_result($result);?> > > The database is a user login database. When they create an account, it sets > the Active field to no, and they have to follow a lonk sent to them by > E-Mail to active the account. > > I want the above script to say Account not active when they try to login > using an account that hasn't been actovated by following the E-Mailed link. > > But, it doesn't, it just returns a blank page. What am I doing wrong? > > The DB_xxx variables are read from a conf file, and the $user is read from > the url > > -- Ben Cairns, Head Of Technical Operations, Intasept.com > E-Mail: BenC@intasept.com | Web: > http://www.intasept.com in general, i suggest to turn on error reporting on in php.ini while developing. then you get the errors from mysql and you can see whats wrong! because you get nothing on your screen, there must be an error/warning from mysql. try an echo of each returned variable. hint: make your $active a integer dichotom variable ( 0=not active, 1= active). in my opinion its easier to use for controlling, have a look on the reset syntax (array functions) in phpmanual too. for further help post again. hope it helps friedhelm betz p.s.: let me/us know if and how you managed! > PHP Windows Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-windows-unsubscribe@lists.php.net > For additional commands, e-mail: php-windows-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.windows (#4103) next »