Some times simple else if doesn't want to work >:<

what is wrong with this?

<div>
						<?php if(in_array(1, $_SESSION['jigowatt']['user_level'])) { ?>
						
						 <h1><?php echo 'Hello'.$profile->getField('name')." ".$profile->getField('last_name')?></h1>
						
						<?php }?>
						<?php else {?>
						<h1><?php  echo 'Hello' ?></h1>
						
						<?php } //else{} ?>
					</div>

getting this stupid erro
PHP Parse error: syntax error, unexpected ‘else’ (T_ELSE)

You have a simple syntax error. You are forgetting to use the colon : at the end of your if and else statements which is necessary using PHP’s alternate syntax and you are including opening and closing braces {} which cannot be used with this syntax. You also need an endif and any time you have a PHP statement you must terminate it with a semi-colon ;.

<?php if($name == 'cheesedude')[COLOR="#0000FF"][B]:[/B][/COLOR]?>
  <h1>Hello <?php echo $name[COLOR="#0000FF"][B];[/B][/COLOR]?></h1>
<?php else[COLOR="#0000FF"][B]:[/B][/COLOR] ?>
  <h1>Hello there stranger!</h1>
<?php endif; ?>

PHP control structure alternate syntax
Mixing PHP and HTML

You don’t have to use the alternate if syntax. What you have will do except when you close the php tags after the if block, what happens is you’re printing output before your “else”.

This part


                        <?php }?>
                        <?php else {?>

Needs to be


<?php } else ?>

Yeah thanks I finally figured that out. thanks… Thanks @cheesedude as well .

Change

 <?php }?> 
                        <?php else {?>

To

 <?php } 
                        else {?>

Ofcourse it wont work if you close PHP tag in the middle of the code…

As an FYI, you may want to read this comment found on http://php.net/manual/en/function.in-array.php

Be aware of oddities when dealing with 0 (zero) values in an array…

This script:

<?php
$array = array('testing',0,'name');
var_dump($array);
//this will return true
var_dump(in_array('foo', $array));
//this will return false
var_dump(in_array('foo', $array, TRUE));
?>

It seems in non strict mode, the 0 value in the array is evaluating to boolean FALSE and in_array returns TRUE. Use strict mode to work around this peculiarity.
This only seems to occur when there is an integer 0 in the array. A string ‘0’ will return FALSE for the first test above (at least in 5.2.6).

If you ever have the value 0 in your array, you could get unwanted results… so be sure to test for that.