Problem with echo' and variable

Hello,

First of all I wanted to know, what means echo’. Not “echo” I mean “echo’”

Second question I want to add something where it says you are logged in as $username. but it doesnt work… any help?

[php]<?php
session_start();
include “auth.php”;
$username = $_SESSION[‘username’];

//Require header.php
require(‘header.php’);

		echo "<h3>HERE IT WORKS $username</h3>";
		
		echo'
		<span class="clear upperframe"><span></span></span>
		<div class="roundframe"><div class="innerframe">';
		echo'
                    //here it doesn't...
		<div class="cat_bar">
		echo "<h3 class="catbg">Ingame CP Logged in as $username</h3>"; 

		</div>
		 //here it isn't working too
	    <p>You are logged in with $username! =).</p>';
		echo'
		
	   </div></div>
	  <span class="lowerframe"><span></span></span>';

//Require Footer,php
require(‘footer.php’);
?>[/php]

I think it has something to do with the echo’ but I rly don’t know… Hope for help…

And when I try to remove the echo’ this error appears:

[12-Feb-2014 06:41:49 America/Los_Angeles] PHP Parse error:  syntax error, unexpected '<' in /home/flyingre/public_html/ingame/login-index.php on line 18

All regards, Mark

[php]echo “

Ingame CP Logged in as $username

”; [/php]

this is beeing parsed as

language construct
[php]echo[/php]

string
[php]"<h3 class="[/php]

constant
[php]catbg[/php]

string
[php]">Ingame CP Logged in as $username"[/php]

[hr]

Which is obviously not what you want.

Either change
[php]class=“catbg”[/php]

to
[php]class=‘catbg’[/php]

or escape the quotes
[php]class=“catbg”[/php]

[hr]

Either will change the parsing to

language construct
[php]echo[/php]

string
[php]"<h3 class=“catbg”>Ingame CP Logged in as $username"[/php]

still not working…

I changed it to: [php]echo “<h3 class=“catbg”>Ingame CP Logged in as $username”[/php]

it has something to do with the echo"[size=18pt]’[/size]"

can you explain why there is a “[size=18pt]’[/size]” after echo?

when I remove them completly I get a blank site…

now it looks like this:

http://imageshack.com/a/img819/7527/41uv.png

Just to add, not directly related to your problem but your markup is not up to scratch.

If you need any help with it, post another message and we’ll help you out.

yes it’s a custom smf php page. Umm there should be still a solution for this problem? :open_mouth:

Yeah I tried inserting your code into my IDE and it’s a mess.

Do you use an IDE? If you get color formatting you should be able to see what’s wrong. It’s a mix of quotes/uneccesary echo’s/etc.

I would recommend doing it like this:

[php]<?php
session_start();
include “auth.php”;
$username = $_SESSION[‘username’];
//Require header.php
require(‘header.php’);
?>

HERE IT WORKS <?= $username ?>

Ingame CP Logged in as <?= $username ?>

You are logged in with <?= $username ?>! = ).

<?php //Require Footer,php require('footer.php'); [/php]

It’s not exactly a problem but rather a ‘best practice’ which would be to use correct markup. Do you have a preview of the page and I’ll write it back out for you?

Sponsor our Newsletter | Privacy Policy | Terms of Service