Andrew Meininger7,615 Points
Working remotely: after I saved the file as a .php extention did my file show up on Chrome as code instead of a webpage?
I saved my file as .php, opened with Chrome and it spits out the code rather than the site itself
If you open it as a file then you'll see the file contents. You need to have it served up by a server that can handle PHP pages. E.g., if you have MAMP installed on a Mac, make sure the servers are started, then open the page from localhost.
Calvin Secrest24,135 Points
I am having trouble with this issued also, after I saved the file from my Atom text editor with my /Documents/Sites/dev/Personal Media Library/s1v1 path. While inside Root Document from my MAMP local server it still doesn't open the index.php file in Chrome browser. I'm not sure what this causing this issue even after I turn on my MAMP server the index.php file will not display.
Sean, if you changed the port number as TH instructed, then you are using the default and you don't need to put in a port number, and, indeed, then, if you do add 8888 localhost:8888 won't work.
So, the check list is as follows: (1) make sure MAMP is running (that is, that both the web server and the database server are running), (2) make sure your URL is correct, (3) make sure the php page is in the folder you put in the URL, (4) make sure that folder is either inside MAMP > htdocs, or the folder to changed the web server's root directory to, and (5) make sure the php page is really a php page. It sounds like you've done 1 - 4, so the spotlight turns to the php itself. Try a very simple php page. Something like this:
<html> <head> <title>PHP Test</title> </head> <body> <?php echo '<p>Hello World</p>'; ?> </body> </html>
Name it test.php, put it in the root folder (which appears to be s1v1), put http://localhost:8888/s1v1/test.php, and see if it works.
Calvin Secrest24,135 Points
@jocrum: I didn't realize my port wasn't config to host the index.php on my local server. Thanks for sharing your input on this topic.
Sean Pierce Sumler18,968 Points
I'm also having trouble with this. Using MAMP I'm able to serve up the index.html file no problem, but after renaming the file to index.php it no longer works. If anyone has any ideas of what I can do to solve this please let me know. Thanks!
Sean, can you copy the entire URL in the address bar of your browser and paste it in a comment so I can see it?
Sean, I don't see any php page in your URL. Plus, if you are using MAMP with the defaults, it would be:
assuming s1v1 is a directory or folder, and pagename is the name of the php file.
On a Mac, if you've reset the ports to 80 and 3306, all you need to type as the url is "localhost". Checkout the setting up a server environment link from the first video in this module to see how to reset the ports.
Note, you need to delete the index.html file (this confuses my Mac), so that all you have is index.php in your root folder.
Matt Bryant10,164 Points
Hi folks, I'm having the same issue that Sean had above - the index.html page shows up just fine in the MAMP My Website preview, but when I rename the file to index.php, I just get a blank page. I am on a Mac. I went through the local MAMP setup video course for Mac, and it has been working fine even before this course. My root folder in the MAMP setup is pointing to this project (like I said, the default index.html shows up just fine), ports are set to 80/80/3036, and my URL per the setup video is localhost. Any other ideas? Thanks!
UPDATE: Nevermind, I figured it out. But I will leave this here in hopes that it might help others. I made a mistake in the PHP code that the instructor has us add for the copyright at the bottom of the page..I forgot the semicolon after the date("Y"); Clearly all it takes is for one character or symbol to be wrong in the PHP for the page not to load at all...like she said, PHP is way more unforgiving than HTML!