Reply
While Clause Failure ??? WTF help
Old 09-23-2007, 08:14 PM While Clause Failure ??? WTF help
amw_drizz's Avatar
Ultra Talker

Posts: 301
Name: Jon
Location: New York
okay some issues been a while since i wrote php or been on this site for that matter.

I am working on a login system for my users and my while clause is failing and the way the page is templated wont display an error if i put
PHP Code:
or die(mysql_error()) 
at the end of it here is the snippet

PHP Code:

$res 
"SELECT * FROM users WHERE usrnm='"$usr ."'";
$subres mysql_query($res) or die('FAIL1');
while(
$usrtst mysql_fetch_array$subres ) or die('FAIL2')) {
        if(
$pwd == !$usrtst['pwd']){
            echo 
'<form method="post" action="/scripts/doLogin.php">
           <div align="center" class="style69">
             <p>Quick Login:<br />
               Username<br />
                   <input name="username" type="text" id="username" />
                     <br />
               <strong><font color="#FF0000">Password is Invalid </font></strong><br />
               <input name="password" type="password" id="password" />
               <br />
               <input type="submit" name="Submit" value="Submit" />
               <br />
               <input name="remberme" type="checkbox" id="remberme" value="yes" />
             Remember Me </p>
             </div>
        </form> '
;
        } 
though testing i found it was this line failing (notice or die('FAIL2')) yet this script works on my login processor so i dont know were i am going wrong, as this script is checking a cookie for a user name and password, check the username against the db, then validates if the pass is correct or not if it is then continues and if it fails then it redisplays the form with bold red font face to indicate a bad password in the cookie (ie someone spoofed or tampered it)

hope that helps with details thanks in advance for the help
__________________
AMW_Drizz
Php 5.2 Mysql 4.1 IIS 6 Win2k3 Server && PHP 5.2 MySQL 4.1 Apache 2.2 (separate machine of course)

Last edited by amw_drizz : 09-23-2007 at 08:17 PM. Reason: forgot something ;)
amw_drizz is offline
Reply With Quote
View Public Profile Visit amw_drizz's homepage!
 
When You Register, These Ads Go Away!
     
Old 09-23-2007, 09:04 PM Re: While Clause Failure ??? WTF help
amw_drizz's Avatar
Ultra Talker

Posts: 301
Name: Jon
Location: New York
figuered it out by doing some more research in to mysql commands for php

i changed this
PHP Code:
while($usrtst mysql_fetch_array$subres ) or die('FAIL2')) { 
to this
PHP Code:
while($usrtst mysql_fetch_row$subres )) { 
Um nevermind didnt work, forgot to test completly and it failed.... AGAIN...
__________________
AMW_Drizz
Php 5.2 Mysql 4.1 IIS 6 Win2k3 Server && PHP 5.2 MySQL 4.1 Apache 2.2 (separate machine of course)

Last edited by amw_drizz : 09-23-2007 at 09:07 PM.
amw_drizz is offline
Reply With Quote
View Public Profile Visit amw_drizz's homepage!
 
Old 09-25-2007, 01:16 PM Re: While Clause Failure ??? WTF help
Junior Talker

Posts: 3
Name: Joe
I think it's missing a '}'. You are closing the if, but not the while.

Hi, this my first post
mrSnacks is offline
Reply With Quote
View Public Profile
 
Old 09-25-2007, 06:10 PM Re: While Clause Failure ??? WTF help
amw_drizz's Avatar
Ultra Talker

Posts: 301
Name: Jon
Location: New York
figured it out, finally

my dumb self had set the db user and password vars the same as the vars called from the cookie but had the require_once listing after calling the vars, so instead of using the vars from the cookie it used the vars from the config file, so i changed the config file to use different vars so instead of $usr i changed it to $dbusr.

works now
__________________
AMW_Drizz
Php 5.2 Mysql 4.1 IIS 6 Win2k3 Server && PHP 5.2 MySQL 4.1 Apache 2.2 (separate machine of course)
amw_drizz is offline
Reply With Quote
View Public Profile Visit amw_drizz's homepage!
 
Old 09-25-2007, 07:19 PM Re: While Clause Failure ??? WTF help
tripy's Avatar
Fetchez la vache!

Posts: 1,924
Name: Thierry
Location: In the void
you are storing an user/password in a cookie !!!???
NAUGHTY !!!!!
__________________
Listen to the ducky: "This is awesome!!!"

tripy is offline
Reply With Quote
View Public Profile
 
Old 09-25-2007, 07:21 PM Re: While Clause Failure ??? WTF help
NullPointer's Avatar
Will Code for Food

Posts: 471
Name: Matt
Location: Irvine, CA
Quote:
Originally Posted by tripy View Post
you are storing an user/password in a cookie !!!???
NAUGHTY !!!!!
He's right... thats a bad idea.
__________________
http://tinsology.com/ - Under construction
NullPointer is offline
Reply With Quote
View Public Profile
 
Old 09-26-2007, 03:29 PM Re: While Clause Failure ??? WTF help
amw_drizz's Avatar
Ultra Talker

Posts: 301
Name: Jon
Location: New York
the password is only stored if the user checks remberme then when it is stored in the cookie it is stored in its MD5 state and the cookies are set to expire in 8 hrs

the connection between server is https and it is on an internal, i will rewrite the login to require users to enter the password everytime the site is loaded in to the browser after i am done making it, as it would be annoying everytime i close the browser (accidently or on purpose) to reenter the password esp if the page dont load correctly or i am debugging it.
__________________
AMW_Drizz
Php 5.2 Mysql 4.1 IIS 6 Win2k3 Server && PHP 5.2 MySQL 4.1 Apache 2.2 (separate machine of course)
amw_drizz is offline
Reply With Quote
View Public Profile Visit amw_drizz's homepage!
 
Reply     « Reply to While Clause Failure ??? WTF help
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.14472 seconds with 13 queries