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 Build a Simple PHP Application Creating the Menu and Footer Starting the Project

Christine Villa
Christine Villa
5,273 Points

Problems with PHP executing

Hello, I downloaded Xampp and at first it worked. I was able to input the code that constantly changed the time. However, today when I was trying to start the project, even after I changed the name to a .php extension, I still saw the code in the browser. I went back to the test.php and it no longer changed the time. Any ideas? I would be very appreciative!

4 Answers

Christopher Hall
Christopher Hall
9,052 Points

I agree with Stone Preston, it seems like XAMPP (in this case Apache, the web server) may not be running. If you checked and it is running, then perhaps you are trying to open the php file directly in the browser, instead of putting it in your htdocs directory and referring to it via localhost, like: /localhost/yourfile.php

Stone Preston
Stone Preston
42,016 Points

did you start your xamp server? It must be running for the code to execute. I havent used xamp but im sure there is some sort of control panel that lets you start and stop your server.

Christine Villa
Christine Villa
5,273 Points

Thanks--it was a combination of starting xampp and trying to run it from my browser. :o)

Hi Christine, can you tell us what text editor are you using? The problem can have a few possibilities, one of them is that the php module for apache has been disabled, but that implies editing the httpd.conf file, the other one is that your apache server hasn't the directive for php files, as well that implies to edit the http.conf file, and one last one is that the file extension for the php file is not correct, this could happen is you're using notepad.

I can't tell for sure what's happening to your installation, but i recommend you try to do a new php file with the following code:

<?php
   phpinfo();
?>

And use sublime text or notepad++ for create that file. I hope it works, if not, try reinstalling XAMMP in case some configuration file is broken.

Christine Villa
Christine Villa
5,273 Points

Thanks for responding. It turns out it was a combination of not starting xampp (I guess I have to start it each time) and trying to open the file from my browser. :o)

Christine Villa
Christine Villa
5,273 Points

Thank you! I did try running it from my browser without referring to it as "/localhost/etc..." I also had to make sure my Xampp was running. I didn't know I had to do it each time. Thanks again!