0

I am learning how to code in PHP and MySQL and I am running into trouble with my HTML calling up PHP. The code looks like:

<form method="post" action="report.php">

When I ran the PHP and HTML on web server (hosted by GoDaddy), the code worked fine.

However, now I am running on a local server (using Apache and MySQL on my Mac Snow Leopard) and I am getting errors. When PHP gets called, a dialogue window pops up saying that "I have chosen to open report.php" and asking if I want to open it with a text editor or save it. I am using FireFox 3 and it's the same dialogue window that appears when opening up a file.

Do I need to do something in particular when I am using my local server? Do I need to save my files in a particular location?

I've spent a long time trying to fix this so any help would be greatly appreciated!

3 Answers 3

2

Have you opened /etc/apache2/httpd.conf and enabled the php5 module?

Should be able to uncomment this line:

LoadModule php5_module        libexec/apache2/libphp5.so
Sign up to request clarification or add additional context in comments.

6 Comments

Like Dagon says below, make sure you're running on the HTTP protocol. Assuming your files are in the "Sites" folder Sites/mynewwebsite/index.php, then you should be able to connect with localhost/~yourusername/mynewwebsite
Yes I did that. Is there something else I should do?
I put my files in /Library/WebServer/Documents
Did you restart the apache server once you enabled php5? I've got to admit, that I've forgotten to do that before.
Yes I did. I think I am starting to solve...but the last question is: how do I find my username and password for MySQL?
|
0

This sounds like a server configuration issue. Apache doesn't know what to do with PHP files and is giving them back to the browser instead of executing them. This generally means PHP is not installed properly. Check in your httpd.conf file that the correct AddType directives have been added so that Apache knows about the PHP interpreter.

Comments

0

you need to open the file via the server not a directory so in your browser something like http://localhost/file.php

2 Comments

I just tried to open via localhost/file.html and the HTML file opened correctly. It's a form and so when I filled out the form and hit submit (at which point the PHP gets called) I get this error: Warning: mysqli_connect() [function.mysqli-connect]: [2002] No such file or directory (trying to connect via unix:///var/mysql/mysql.sock) in /Library/WebServer/Documents/report.php on line 23 Warning: mysqli_connect() [function.mysqli-connect]: (HY000/2002): No such file or directory in /Library/WebServer/Documents/report.php on line 23 Error connecting to MySQL server.
Ok I checked my code and I know what I did. How do I find my MySQL username and password? I am using a terminal. Thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.