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

Help please!

Any reason this simple code doesn't work?

<html>
<head><title><?php echo "Shirts 4 Mike"; ?></title>
</head>
    <body>&copy; <?php echo date('Y'); ?>
    </body>
</html>

This is a copy of Xampp control panel: 1:19:57 PM [main] Initializing Control Panel 1:19:57 PM [main] Windows Version: 32-bit 1:19:57 PM [main] XAMPP Version: 1.8.1 1:19:57 PM [main] Control Panel Version: 3.1.0 3.1.0 [ Compiled: September 20th 2012 ] 1:19:57 PM [main] Running with Administrator rights - good! 1:19:57 PM [main] XAMPP Installation Directory: "c:\xampp\" 1:19:57 PM [main] Checking for prerequisites 1:19:57 PM [main] All prerequisites found 1:19:57 PM [main] Initializing Modules 1:19:57 PM [Apache] XAMPP Apache is already running on port 80 1:19:57 PM [Apache] XAMPP Apache is already running on port 443 1:19:57 PM [main] Starting Check-Timer 1:19:57 PM [main] Control Panel Ready

this code should be working, i don't know why not. Also im using firefox. Could they be the difference? wouldn't think so, i will check in chrome. nope, didn't work.

this is my root: file:///C:/xampp/htdocs/projects/sample.php

6 Answers

What is it not doing or is doing that's not expected?

it's just not running it. in the title it gives me my php code as if i saved it in Html.
and in the body it just gives me the @ without the date. Just not recognizing the php at all.

Do you have it saved as a php file? It worked for me

yea i do. im thinking that it's the Xampp server somehow.

[06-Jun-2013 03:11:32 UTC] PHP Warning: file_get_contents(lang.tmp): failed to open stream: No such file or directory in C:\xampp\htdocs\xampp\index.php on line 2

the error msg on the php log file on Xampp control panel somethings wrong with the configuration i guess. so frustrating!

I'm using XAMPP...worked just fine.

Seems like you're missing a file XAMPP needs

yea im sure. im saying that it's my configuration. perhaps not configured correctly yea, however i checked that directory and the file is there.

Might be easier just to reinstall it from a fresh download. I didn't have to ever configure anything on mine once it was installed.

yup. i always have to change the ports on skype because it always conflicts with xamp. that's the only thing i did.

Ahh, I've heard of that issue before. I don't have skype on this computer. I'm not of much help here...I don't exactly know the file hierarchy of XAMPP. Maybe someone smarter will come along and provide an easier fix than re installing from scratch.

lol yeah. everything else is working. i've had this problem before to that's why i knew what to do. just change the ports that skype communicates on. but something else up with this. i will try the reinstall.

I SEE THE PROBLEM!!!

FOR ANYONE WHO HAS THIS PROBLEM WITH PHP. PHP WILL NOT WORK UNLESS YOU CALL IT IN THE BROWSER FROM LOCALHOST/ IF YOU JUST CLICK ON THE PHP FILE, IT WILL OPEN IN THE BROWSER BUT THE PHP CODE WILL NOT WORK.

When online, writing in ALL caps is considered yelling, please don't do that on the forum.

Thanks and happy forum'ing.