Jump to content

[SOLVED] echo problem


chanfuterboy

Recommended Posts

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

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

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

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

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

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.