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.

Link to comment
Share on other sites

<?
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...

Link to comment
Share on other sites

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";
}
?>

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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!

 

Link to comment
Share on other sites

<?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>';
}
?>

Link to comment
Share on other sites

<?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!!

Link to comment
Share on other sites

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>';
}
?>

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.