chanfuterboy Posted August 19, 2009 Share Posted August 19, 2009 hi, always when im going to echo something i will get problem. Someone can help me, if user is login show the html code, if not register show nothing <?php if(!$_SESSION['userid']) { echo "<p align='right'> <img src='http://www.awortinkos.com/realgame/styles/pm.png'><b> <font color='#FFFFFF'>PM <?php echo $newpm; ?></font></b> <img src='http://www.awortinkos.com/realgame/styles/invite.png'> <b> <font color='#FFFFFF' face='Verdana' size='2'>friends <?php echo $newfr; ?></font></b></p>"; </head> <body> ?> Link to comment https://forums.phpfreaks.com/topic/171028-solved-echo-problem/ Share on other sites More sharing options...
Monadoxin Posted August 19, 2009 Share Posted August 19, 2009 When printing HTML, it is best to use single quotes. <?php if(!$_SESSION['userid']) { echo '<p align="right"> <img src="http://www.awortinkos.com/realgame/styles/pm.png"><b> <font color="#FFFFFF">PM '. $newpm .'</font></b> <img src="http://www.awortinkos.com/realgame/styles/invite.png"> <b> <font color="#FFFFFF" face="Verdana" size="2">friends '. $newfr .'</font></b></p> </head> <body>'; ?> Link to comment https://forums.phpfreaks.com/topic/171028-solved-echo-problem/#findComment-902014 Share on other sites More sharing options...
chanfuterboy Posted August 19, 2009 Author Share Posted August 19, 2009 strange the page is showing :: website can not be found, the script dont pickup the page Link to comment https://forums.phpfreaks.com/topic/171028-solved-echo-problem/#findComment-902016 Share on other sites More sharing options...
chanfuterboy Posted August 19, 2009 Author Share Posted August 19, 2009 there is still error on the code <?php if(!$_SESSION['userid']) { echo '<p align='right'> <img src='http://www.awortinkos.com/realgame/styles/pm.png'><b> <font color='#FFFFFF'>PM '. $newpm .'</font></b> <img src='http://www.awortinkos.com/realgame/styles/invite.png'> <b> <font color='#FFFFFF' face='Verdana' size='2'>friends '. $newfr .'</font></b></p> </head> <body>'; ?> plz help Link to comment https://forums.phpfreaks.com/topic/171028-solved-echo-problem/#findComment-902023 Share on other sites More sharing options...
oni-kun Posted August 19, 2009 Share Posted August 19, 2009 You're using single quotes for the HTML. If you wrap HTML in a single quote, only use double quotes such as.. '<font color="#FFFFFF">'; And not: '<font color='#FFFFFF'>'; Link to comment https://forums.phpfreaks.com/topic/171028-solved-echo-problem/#findComment-902025 Share on other sites More sharing options...
chanfuterboy Posted August 19, 2009 Author Share Posted August 19, 2009 yes i thought if its in php should be only 1, but both script does not work, there is somewhere a error Link to comment https://forums.phpfreaks.com/topic/171028-solved-echo-problem/#findComment-902028 Share on other sites More sharing options...
jonsjava Posted August 19, 2009 Share Posted August 19, 2009 I'm a big fan of heredoc. Basically, you tell it to echo until a certain string has been reached: <?php if(!$_SESSION['userid']) { echo <<<EOF <p align='right'> <img src='http://www.awortinkos.com/realgame/styles/pm.png'><b> <font color='#FFFFFF'>PM $newpm</font></b> <img src='http://www.awortinkos.com/realgame/styles/invite.png'> <b> <font color='#FFFFFF' face='Verdana' size='2'>friends <?php echo $newfr; ?></font></b></p>"; </head> <body> EOF; } ?> It usually solves echo issues. Link to comment https://forums.phpfreaks.com/topic/171028-solved-echo-problem/#findComment-902032 Share on other sites More sharing options...
oni-kun Posted August 19, 2009 Share Posted August 19, 2009 yes i thought if its in php should be only 1, but both script does not work, there is somewhere a error Well lets try to fix your code, tell us all the results/errors you receive. <?php if(!$_SESSION['userid']) { echo '<p align="right"> <img src="http://www.awortinkos.com/realgame/styles/pm.png"><b> <font color="#FFFFFF">PM '. $newpm .'</font></b> <img src="http://www.awortinkos.com/realgame/styles/invite.png"> <b> <font color="#FFFFFF" face="Verdana" size="2">friends '. $newfr .'</font></b></p> </head> <body>'; ?> Wait.. Why is your PM code in <head>? It won't show..place it in body.. You can only do it something like this.. <?php if(!$_SESSION['userid']) { echo '</head><body><p align="right"> <img src="http://www.awortinkos.com/realgame/styles/pm.png"><b> <font color="#FFFFFF">PM '. $newpm .'</font></b> <img src="http://www.awortinkos.com/realgame/styles/invite.png"> <b> <font color="#FFFFFF" face="Verdana" size="2">friends '. $newfr .'</font></b></p>'; ?> Link to comment https://forums.phpfreaks.com/topic/171028-solved-echo-problem/#findComment-902035 Share on other sites More sharing options...
chanfuterboy Posted August 19, 2009 Author Share Posted August 19, 2009 thanks, that EOF has does it Link to comment https://forums.phpfreaks.com/topic/171028-solved-echo-problem/#findComment-902038 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.