Jump to content

Probably real simple


Phpfr3ak

Recommended Posts

Getting an unexpected end error on this and unsure as to why.

 

<?php if($players['is_banned'] == 1) { ?>
<a href="profile.php?id=<?php echo $players['id'] ?>"><?php echo $players['name']  ?> (BANNED)
<? }else{ ?>
<a href="profile.php?id=<?php echo $players['id'] ?>"><?php echo $players['name']  ?>
<? } ?>

Link to comment
https://forums.phpfreaks.com/topic/254943-probably-real-simple/
Share on other sites

Actually, you don't need ; right before a closing ?> tag.

 

Your unexpected $end error is probably because you are using short open tags and they are not enabled on your server. Be constant and always use full opening <?php tags in your code so that your code will always be seen as being php code.

 

Why are you using so many opening and closing php tags in your code?

 

<?php
if($players['is_banned'] == 1) {
echo "<a href='profile.php?id={$players['id']}'>{$players['name']} (BANNED)</a>";
}else{
echo "<a href='profile.php?id={$players['id']}'>{$players['name']}</a>";
}

 

Or even simpler -

<?php
echo "<a href='profile.php?id={$players['id']}'>{$players['name']} ",($players['is_banned'] == 1) ? '(BANNED)' : '',"</a>";

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.