Jump to content

can somene tell me what is wrong with this simple code?


starvator

Recommended Posts

<?
if($session->logged_in){
   <embed height="200" width="90%" src="http://en.gagalive.com/livechat1.swf?chatroom=LeetGiveaways"></embed>;
   }
   else{ echo "hi";
?>

 

can someone please tell me what is wrong with this code?

 

thanks!

 

1. You shouldn't use short tags.  Instead, use the full <?php ?> pair.

2. You can't output HTML in your if-statement in the manner that you're trying.  Either echo/print it, or exit PHP.

3. Like Alex said, you're missing a closing '}' at the end of the else.

4. This looks very much like a homework question, which we generally frown on here.

<?
if($session->logged_in){
   <embed height="200" width="90%" src="http://en.gagalive.com/livechat1.swf?chatroom=LeetGiveaways"></embed>;
   }
   else{ echo "hi";
?>

 

can someone please tell me what is wrong with this code?

 

thanks!

 

1. You shouldn't use short tags.  Instead, use the full <?php ?> pair.

2. You can't output HTML in your if-statement in the manner that you're trying.  Either echo/print it, or exit PHP.

3. Like Alex said, you're missing a closing '}' at the end of the else.

4. This looks very much like a homework question, which we generally frown on here.

 

nope, its not hwk, im just learning :P  I have a login script and want to customize it by showing the chat if the user is logged out and if they are logged in, then it just says hi...

 

I tried fixing it by adding the closing bracket, but it still does not work...

Did you fix what Nightslyr added?

 

<?php
if($session->logged_in){
    echo '<embed height="200" width="90%" src="http://en.gagalive.com/livechat1.swf?chatroom=LeetGiveaways"></embed>';
} else { 
    echo "hi";
}
?>

You should be more specific.

 

If that's the entire code then you're missing a closing }.

 

I have an entire login system, but thats the only thing im trying to add, i want to put an iframe if the user is not logged in and if they are logged in, then only sais hi.

 

please help!

Did you fix what Nightslyr added?

 

<?php
if($session->logged_in){
   echo '<embed height="200" width="90%" src="http://en.gagalive.com/livechat1.swf?chatroom=LeetGiveaways"></embed>';
} else { 
    echo "hi";
}
?>

 

wow that woks... but y?  what's nightslyr?

2. You can't output HTML in your if-statement in the manner that you're trying.  Either echo/print it, or exit PHP.

 

You can't just place html anywhere. Just like you echoed 'hi' you needed to echo the html.

2. You can't output HTML in your if-statement in the manner that you're trying.  Either echo/print it, or exit PHP.

 

You can't just place html anywhere. Just like you echoed 'hi' you needed to echo the html.

 

I guess that makes sense...

<?php
if($session->logged_in){
   echo '<embed height="200" width="90%" src="http://en.gagalive.com/livechat2.swf?chatroom=leetgiveaways&user=UserID"></embed>';
} else { 
    echo  '<embed height="200" width="90%" src="http://en.gagalive.com/livechat2.swf?chatroom=leetgiveaways"></embed>';
}
?>

 

So this is my final code :D

 

one mini problem...

 

src="http://en.gagalive.com/livechat2.swf?chatroom=leetgiveaways&user=UserID"></embed>';

 

If I change the word UserID to like Banna , thats what shows up in the chat.  How can i say to grab that from my already existing user database?

 

how can I add $session->username

 

thanks!

 

<?php
if($session->logged_in){
   echo '<embed height="200" width="90%" src="http://en.gagalive.com/livechat2.swf?chatroom=leetgiveaways&user=' . $session->usrername . '"></embed>';
} else { 
    echo  '<embed height="200" width="90%" src="http://en.gagalive.com/livechat2.swf?chatroom=leetgiveaways"></embed>';
}
?>

<?php
if($session->logged_in){
   echo '<embed height="200" width="90%" src="http://en.gagalive.com/livechat2.swf?chatroom=leetgiveaways&user=' . $session->usrername . '"></embed>';
} else { 
    echo  '<embed height="200" width="90%" src="http://en.gagalive.com/livechat2.swf?chatroom=leetgiveaways"></embed>';
}
?>

' . $session->usrername . '

does not seem to work... is there another way?

 

thx!!

Small typo on my part, sorry.

 

<?php
if($session->logged_in){
   echo '<embed height="200" width="90%" src="http://en.gagalive.com/livechat2.swf?chatroom=leetgiveaways&user=' . $session->username . '"></embed>';
} else { 
    echo  '<embed height="200" width="90%" src="http://en.gagalive.com/livechat2.swf?chatroom=leetgiveaways"></embed>';
}
?>

Small typo on my part, sorry.

 

<?php
if($session->logged_in){
   echo '<embed height="200" width="90%" src="http://en.gagalive.com/livechat2.swf?chatroom=leetgiveaways&user=' . $session->username . '"></embed>';
} else { 
    echo  '<embed height="200" width="90%" src="http://en.gagalive.com/livechat2.swf?chatroom=leetgiveaways"></embed>';
}
?>

 

YOU ARE GODDDDDDDLIKE!!

 

THANKYOUUUU

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.