Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP PHP Basics (Retired) PHP Data & Structure PHP Variables

Challenge Task 2 of 2 in PHP Basics

I feel like I must be missing something obvious because for whatever reason, I can't get passed this simple challenge. Anybody see what I'm missing? Thanks in advance for any help.

Challenge: "Now echo Mike's Name To The Screen".

Here is my code, which almost exactly matches what was in the video itself. I've surrounded it with 'body' and 'h1' tags as well and still nothing.

<?php $name = "Mike"; ?>

<h1> <?php echo $name ?> </h1>

Each time, I get this as a response:

Bummer! I am not seeing the word "Mike" in the output. Did you echo something different?

23 Answers

You are missing a semi-colon after the name variable in the echo statement, and you only need one php block.

both your variable decleration and your echo statement should go inside of a single php block

<?php

variable decleration here

echo statement here

?>

Had issues with this despite it being the correct code, let's see a fix TH!

I found a possible fix. Refresh your browser and paste in the code again. Should Work.

Dear Treehouse,

Fix this as there really should be several ways to write the code and none of them are worse really wrong if they meet the task goals.

You're missing a semi-colon after the name variable, but with that fixed it's still not passing for me.

So technically you're right, Treehouse just doesn't want to give you your 6 points.

<?php

$name = "Mike";
echo $name;

?>

This is what I wrote, and I am still getting the Bummer...

I placed a space between the semi-colon and the declarations and it worked!

Is it supposed to be this way?

This worked for me thank you

There is a small bug because I wrote the exact same as everyone else here but this line of code should work

<?php 

$name = "Mike";
echo $name ;

?>

And no you shouldn't have to put spaces in between decelerations

I have written it exactly as you have and still get the error.. wtf..

David Brenecki I'm not sure where you're getting the error but a step by step is this

Open your php tags, then make a variable named "name" give it a string called "Mike"

<?php
$name = 'Mike';
?>

Echo $name

<?php 
$name = 'Mike';
echo $name;
?>

This is a browser issue. I was using Google Chrome with no avail and then tried using Internet Explorer and it worked just fine.

Treehouse u need to fix this

The problem is still not fixed

<?php $name = "Mike"; echo $name; ?> this worked for me after a long frustrating trials....

This still doesn't work. Tried all the above fixes plus my own experimentation and nothing. Pretty poor to be frank.

Adam, you're right on the missing semi-colon but since it's on it's own line, I didn't think it was necessary, and they didn't include a semi-colon in the video.

After using Ryan's technique and putting everything inside of the same PHP block, it finally worked. I had assumed it wanted something in a separate block outside of the initial PHP block.

Thanks to both of you for your help!

I had an issue with this challenge also, turns out I had a <b>blank line 1 and started my code on line 2</b>... deleting the empty line 1 and starting the code on the first line fixed the issue.

Can someone confirm that this is correct? I"m just wondering, because I went back to the video and it pretty much matches verbatim with the exception of the semicolon. (I think that with one line of Php you don't need the semi-colon???)

<?php $name="Mike";?>

<?php echo $name; ?>

<?php $name = "Mike"; echo $name; ?>

I did this and it said "Bummer! I am not seeing the word "Mike" in the output. Did you echo something different?"

Any suggestions?

<?php $name = "Mike"; echo $name; ?>

This code works.

It worked for me

I had the same issue, until I backspaced the opening <?php so there was was no whitespace at the start, then bingo.

Wouldn't be an issue in reality, bug with the test.

Yeah, I would try a simple refresh to those of you still having issues. It's unlikely that it's an actual issue with your content. Luckily these steps are fairly painless so a refresh won't lose much progress.

Should work after.

<?php

$name = "Mike"; echo $name;

?>

I am trying the same code and not working.

I'm not sure what the issue is. Your code looks right other than it is not best practice to put two statements on one line, but when I run the code from your example, it works. The code provided below works for me in Chrome Version 43.0.2357.134 m, Firefox Version 39.0, IE Version 11.0.9600.17905, Safari Version 5.1.7 for windows. Hope this helps.

<?php

$name = "Mike";

echo $name;

?>

Use IE and it will work.

<?php $name = "Mike" ; echo $name ;

?>

<?php $name = 'Mike';

echo $name;

?>

This is the same code that everyone has. If you are having the same issue with the error message even though your code matches, try refreshing the page and putting the code in again; that eventually worked for me after trying multiple solutions that were to no avail.

<?php

$name = "Mike";

?>

<!DOCTYPE html> <html> <?php echo "Mike"?> </html>

don't forget to include the the the doctype