ngreenwood6 Posted August 5, 2008 Share Posted August 5, 2008 I need some help with an if statement that I am trying to get accomplished. It's kind of confusing but bare with me here. I basically need an if statement inside of an if statement. It just keeps taking me to a blank screen. if($session_username != $new_username)//session username is from their session and new username comes from a form { if ($username_from_db > 0) //if the username is in the database { echo "do this"; } else { echo "do the rest of the first if statement"; } } else { process form } Any help is appreciated. Link to comment https://forums.phpfreaks.com/topic/118304-helf-with-if/ Share on other sites More sharing options...
KevinM1 Posted August 5, 2008 Share Posted August 5, 2008 I need some help with an if statement that I am trying to get accomplished. It's kind of confusing but bare with me here. I basically need an if statement inside of an if statement. It just keeps taking me to a blank screen. if($session_username != $new_username)//session username is from their session and new username comes from a form { if ($username_from_db > 0) //if the username is in the database { echo "do this"; } else { echo "do the rest of the first if statement"; } } else { process form } Any help is appreciated. Are you sure your variables contain values? Because there's no syntax error, other than 'process form' not being commented out. Link to comment https://forums.phpfreaks.com/topic/118304-helf-with-if/#findComment-608804 Share on other sites More sharing options...
ngreenwood6 Posted August 5, 2008 Author Share Posted August 5, 2008 yes the variables contain values. I just put down some sample code that is not actually my code I am just trying to figure out how to correctly put an if statement inside of an if statement. Link to comment https://forums.phpfreaks.com/topic/118304-helf-with-if/#findComment-608815 Share on other sites More sharing options...
obsidian Posted August 5, 2008 Share Posted August 5, 2008 Try combining your checks: <?php if($session_username != $new_username && $username_from_db > 0) { echo "do this"; } else { process form } ?> Hope that makes sense. Link to comment https://forums.phpfreaks.com/topic/118304-helf-with-if/#findComment-608819 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.