starvator Posted April 24, 2010 Share Posted April 24, 2010 <? 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! Quote Link to comment https://forums.phpfreaks.com/topic/199559-can-somene-tell-me-what-is-wrong-with-this-simple-code/ Share on other sites More sharing options...
Alex Posted April 24, 2010 Share Posted April 24, 2010 You should be more specific. If that's the entire code then you're missing a closing }. Quote Link to comment https://forums.phpfreaks.com/topic/199559-can-somene-tell-me-what-is-wrong-with-this-simple-code/#findComment-1047448 Share on other sites More sharing options...
KevinM1 Posted April 24, 2010 Share Posted April 24, 2010 <? 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. Quote Link to comment https://forums.phpfreaks.com/topic/199559-can-somene-tell-me-what-is-wrong-with-this-simple-code/#findComment-1047450 Share on other sites More sharing options...
starvator Posted April 24, 2010 Author Share Posted April 24, 2010 <? 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 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... Quote Link to comment https://forums.phpfreaks.com/topic/199559-can-somene-tell-me-what-is-wrong-with-this-simple-code/#findComment-1047480 Share on other sites More sharing options...
Alex Posted April 24, 2010 Share Posted April 24, 2010 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"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/199559-can-somene-tell-me-what-is-wrong-with-this-simple-code/#findComment-1047481 Share on other sites More sharing options...
starvator Posted April 24, 2010 Author Share Posted April 24, 2010 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! Quote Link to comment https://forums.phpfreaks.com/topic/199559-can-somene-tell-me-what-is-wrong-with-this-simple-code/#findComment-1047482 Share on other sites More sharing options...
starvator Posted April 24, 2010 Author Share Posted April 24, 2010 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? Quote Link to comment https://forums.phpfreaks.com/topic/199559-can-somene-tell-me-what-is-wrong-with-this-simple-code/#findComment-1047483 Share on other sites More sharing options...
Alex Posted April 24, 2010 Share Posted April 24, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/199559-can-somene-tell-me-what-is-wrong-with-this-simple-code/#findComment-1047485 Share on other sites More sharing options...
starvator Posted April 24, 2010 Author Share Posted April 24, 2010 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 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! Quote Link to comment https://forums.phpfreaks.com/topic/199559-can-somene-tell-me-what-is-wrong-with-this-simple-code/#findComment-1047487 Share on other sites More sharing options...
Alex Posted April 24, 2010 Share Posted April 24, 2010 <?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>'; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/199559-can-somene-tell-me-what-is-wrong-with-this-simple-code/#findComment-1047488 Share on other sites More sharing options...
starvator Posted April 24, 2010 Author Share Posted April 24, 2010 <?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!! Quote Link to comment https://forums.phpfreaks.com/topic/199559-can-somene-tell-me-what-is-wrong-with-this-simple-code/#findComment-1047490 Share on other sites More sharing options...
Alex Posted April 24, 2010 Share Posted April 24, 2010 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>'; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/199559-can-somene-tell-me-what-is-wrong-with-this-simple-code/#findComment-1047491 Share on other sites More sharing options...
Pikachu2000 Posted April 24, 2010 Share Posted April 24, 2010 Did you intentionally misspell 'usrername'? Quote Link to comment https://forums.phpfreaks.com/topic/199559-can-somene-tell-me-what-is-wrong-with-this-simple-code/#findComment-1047492 Share on other sites More sharing options...
starvator Posted April 24, 2010 Author Share Posted April 24, 2010 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 Quote Link to comment https://forums.phpfreaks.com/topic/199559-can-somene-tell-me-what-is-wrong-with-this-simple-code/#findComment-1047493 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.