Page 1 of 1

elseif statements

Posted: Sat Apr 07, 2007 7:51 pm
by rxroids
I'm using this code:

Code: Select all

<?php //Middle Initial
				if(!empty($_POST['middle_ini']))
					{
					echo ' '.($_POST['middle_ini']).'.';
					}
					elseif(empty($_POST['first_name'])&&(empty($_POST['middle_ini']))
					{
					echo 'Monkey';
					}
                                        else
                                        {
                                        echo ' ';
                                        }
			?>
If middle_ini is not empty show: ' '.($_POST['middle_ini']).'.' But if first_name AND middle_ini ARE empty show Monkey. Something is wrong with my code cuz i keep gettin an error message.

Posted: Sat Apr 07, 2007 8:00 pm
by aaronhall
What do I win if I go through your code and correctly guess what the error message is?

Posted: Sun Apr 08, 2007 5:55 am
by mentor
Always mention which error you are getting. Rewrite your elseif statment line i.e. line 6.

Posted: Sun Apr 08, 2007 7:39 am
by nitrino
maybe use switch...case instead.