Jump to content
Larry Ullman's Book Forums

Server Isn'T Interpreting Php (Sends Source Html & Php As Text)


Recommended Posts

Hello,

Here is my issue, I had Apache, MySQL, and PHP each installed separately on my local Mac and was able to see .php files in Firefox and Safari fine, everything worked. Then, (for some reason) I decided to uninstall MySQL, to turn off file sharing and install the MAMP package instead. Now my .php files do not show up like you would expect them to, instead the php files show all of the html and php code in the browsers. The browsers show the information that you would normally see in a text editor. I'm pretty sure that I'm typing the URL correctly into the browsers (I"ve tried just about every combination imaginable with the http://localhost/ as part of the name) and I've even switched the Apache document root (multiple times) to see if MAMP is referring to a different directory. I don't know why Apache won't process the PHP or what's going on?!? Files that once worked as .php files now do not. I'm a beginner at this so I don't know if there is something wrong with the php config file or what. Currently I"m only on Chapter 3 about forms and if I drag the html form to the browser it opens fine, then when I fill out the form and click submit it shows me the source text for the handle_form.php file with no error messages or information filled in differently than the original text file. Can someone help, I can't do anything until I can get the php files processing again.

 

Thanks for any help you can give.

Link to comment
Share on other sites

Okay, a few things...

 

- File sharing has no impact here. Web sharing is the key thing to enable for using Mac OS X's built-in Apache.

- If you're using MAMP, then your URL needs to start with http://localhost:8080, I believe. Check the MAMP documentation or view the MAMP Web start page, available through the MAMP control panel.

- You absolutely must, always run PHP files through http. I stress this repeatedly in the book. Loading a PHP script through the file system won't do any good. Loading an HTML form that gets submitted to a PHP script through the file system won't do any good.

- You'll do yourself a big favor if you stop randomly trying things. You're only confusing yourself and making this more complicated.

Link to comment
Share on other sites

Okay,

Thank you for replying so quickly. When I first installed MAMP I switched the Apache Port to 80 and the MySQL Port to 3306. I'll try it again... I typed into the URL address line in the browser: http://localhost:80/Applications/MAMP/htdocs/hello.php and it gives me a 404 message. Then I tried: http://localhost:3306/Applications/MAMP/htdocs/hello.php and Firefox is prompting me to open the php file with a different application. I'm not sure what this all means? Can you help? I don't want to just try random things, but I am without a reasonable solution on my own?

 

Thanks.

Link to comment
Share on other sites

No offense meant at all, but it surprises me that you know about changing ports (let alone how to do that), but you don't know that the MySQL port isn't something you'd use in a URL or that you wouldn't include /Applications/MAMP/htdocs in the URL. Again, no offense meant, but you seem to be doing a weird combination of advanced and very beginner things here.

 

Okay, so if you changed the port to 80, then you don't need to indicate the port in the URL. And also don't have the Mac OS X Web sharing on at the same time, as that uses port 80 by default. Second, the URL localhost already points to the Web root directory. You shouldn't put /Applications/MAMP/htdocs in the URL, as those are file system references. By default, localhost on MAMP points to /Applications/MAMP/htdocs. That is unless you've changed that setting in MAMP.

Link to comment
Share on other sites

No problem, you'll get through this and this forum is here to help. My more specific recommendation beyond not trying random things is definitely not to mess with the OS and Web server system unless you absolutely know you have that need and absolutely understand the implications of what you're doing.

Link to comment
Share on other sites

 Share

×
×
  • Create New...