RE: [PHP] why doesnt this work???

From: Date: Wed, 20 Mar 2002 14:49:46 +0000
Subject: RE: [PHP] why doesnt this work???
Groups: php.general 
Request: Send a blank email to php-general+get-89344@lists.php.net to get a copy of this message
Hi, Let me explain what is wrong with this line: if( $line[1]='$bruker' and $line[2]='$passord') when you use = instead of == it will always be true because you set $line[1] to $bruker, you have to compare them by using ==. Also looking at your sql query $line[0] would contain your username and $line[1] your password! try after $line = mssql_fetch_row($result); echo "DEBUG : $line[0] - $line[1] - $line[2]"; if( $line[1]='$bruker' and $line[2]='$passord') echo "hei $bruker."; else echo "FEIL"; Regards Lars Stampe -----Original Message----- From: chris [mailto:tometerlaks@hotmail.com] Sent: 20 March 2002 14:41 To: php-general@lists.php.net Subject: Re: [PHP] why doesnt this work??? Thanx for all the help guys, but i have tried all of the sugestions but the one that works best is the one i startet with... but that one does not work 100% either...im so confused my head is about to fall of.... i just dont get it... "Robert Collins" <RCollins@NORTA.COM> wrote in message news:D54DBC194E89D411ABA1000629551764601F6F@rtamail.norta.com... > Try this > > > if($line[1] == '$bruker' && $line[2] == '$passord'){ > echo "hei $bruker."; > }else{ > echo "FEIL"; > } > > > Robert W. Collins II > Webmaster > New Orleans Regional Transit Authority > Phone : (504) 248-3826 > Email : rcollins@norta.com > > > -----Original Message----- > From: chris [mailto:tometerlaks@hotmail.com] > Sent: Wednesday, March 20, 2002 8:33 AM > To: php-general@lists.php.net > Subject: Re: [PHP] why doesnt this work??? > > > it all works just fine exept that when the vars is wrong i get a blank > page...wich means that the else echo doesnt work for some reason... and if i > use == the correct vars become wrong... but it does print the else echo... > hmm... > > > "Robert Collins" <RCollins@NORTA.COM> wrote in message > > news:D54DBC194E89D411ABA1000629551764601F6E@rtamail.norta.com... > > instead of 'and' use '&&' > > > > if($line[1] == "$bruker" && $line[2] == "$passord"){ > > echo "hei $bruker."; > > }else{ > > echo "FEIL"; > > } > > > > Robert W. Collins II > > Webmaster > > New Orleans Regional Transit Authority > > Phone : (504) 248-3826 > > Email : rcollins@norta.com > > > > > > -----Original Message----- > > From: R'twick Niceorgaw [mailto:rtwick@niceorgaw.com] > > Sent: Wednesday, March 20, 2002 8:25 AM > > To: php-general@lists.php.net > > Subject: Re: [PHP] why doesnt this work??? > > > > > > You need two = signs for comparision not just one . > > Also I think you need to enclose the variables in double quote. > > > > if( $line[1]=="$bruker" and $line[2]=="$passord") echo > > "hei > > $bruker."; > > else echo "FEIL"; > > > > > > > -----Original Message----- > > > From: chris [mailto:tometerlaks@hotmail.com] > > > Sent: Wednesday, March 20, 2002 8:15 AM > > > To: php-general@lists.php.net > > > Subject: [PHP] why doesnt this work??? > > > > > > > > > this script receives vars "b" and "p" from a form. > > > If "b" and "p" matches the echo on IF, then it works just fine. > > > The problem is that if the vars dont match the ELSE ECHO > > > does not apear... why not? > > > > > > <? > > > $bruker = $HTTP_POST_VARS["b"]; > > > $passord = $HTTP_POST_VARS["p"]; > > > $hostname = "********"; > > > $username = "********"; > > > $password = "********"; > > > $dbname = "********"; > > > MSSQL_CONNECT($hostname,$username,$password); > > > mssql_select_db($dbname); > > > $query = "select * from medlemmer where bruker = '$bruker' and passord = > > > '$passord'"; > > > $result = mssql_query( $query ); > > > for ($i = 0; $i < mssql_num_rows( $result ); ++$i) > > > { > > > > > > $line = mssql_fetch_row($result); > > > if( $line[1]='$bruker' and $line[2]='$passord') echo > > > "hei > > $bruker."; > > > else echo "FEIL"; > > > } > > > ?> > > > > > > -Chris > > > > > > > > > > > > -- > > > PHP General Mailing List (http://www.php.net/) > > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > -- > > > PHP General Mailing List (http://www.php.net/) > > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > > > > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.general (#89344) next »