Jump to content

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

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.