-1

my else statement is not executing it returns a black page.

while($results = mysql_fetch_array($user_name))
         {
			if ($results['email'] == $Entered_UserName && $results['password'] == $Entered_PassWord)
         		echo 'working';
			else
         		echo 'not working';
		}
4
Contributors
4
Replies
5
Views
7 Years
Discussion Span
Last Post by leviathan185
0

my else statement is not executing it returns a black page.

while($results = mysql_fetch_array($user_name))
         {
			if ($results['email'] == $Entered_UserName && $results['password'] == $Entered_PassWord)
         		echo 'working';
			else
         		echo 'not working';
		}

should be

<?php
   while($results = mysql_fetch_array($user_name)) {
      if ($results['email'] == $Entered_UserName && $results['password'] == $Entered_PassWord) {
         echo 'its working';
      } else {
         echo 'its not working';
   }
?>

you missed the {} on the 2nd if statement

1

Technically, it doesn't matter if you have only 1 line statement after a condition. ie.,

<?php
$x = 1;
if($x == 1) 
    echo "$x is valid.";
else 
    echo "$x is invalid";
?>

This will not work if you have more than 2 statements in your condition.
Btw, its not a good practice to miss { } for your conditions.

0

my else statement is not executing it returns a black page.

while($results = mysql_fetch_array($user_name))
         {
			if ($results['email'] == $Entered_UserName && $results['password'] == $Entered_PassWord)
         		echo 'working';
			else
         		echo 'not working';
		}

Check your variable name, that are properly used or check whether the conditional variable assigns the correct information from the user.

0

In that case if the missng {} is not the issue, you may want to check that $user_name contains the relevant information. try a print_r($user_name) before you execute the mentioned code and see if it contains the info you are looking for. Work backwards from there

Edited by leviathan185: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.