Question:
Trying to test PHP scripts but weird error message comes up?
olympikdude
2006-08-26 12:05:57 UTC
Okay, just figuring out PHP, SQL, Apache. I have it all running right, localhost is all set up. I have made a bunch of PHP files and I'm trying to test a simple user registration page.

Everytime I fill out the information (name, email, password, etc.) I click the button "register me" and a box pops up asking me to open the associated PHP file. Why? Why wouldnt the PHP script just run and create the user registration in the database? It always asks me if I want to open or save the PHP file.

Here's my HTML since I know this is somehow the problem.



Pick a Username:



Pick a Password:



Your Email:



Age (#):



...........blahblahblah

Always asking me to open/save register.php
Five answers:
Michael Darnell
2006-08-26 12:39:32 UTC
The script is not being processed by apache - It sounds like you are trying to view the test form without having apache actually 'serve' the file to you. Try typing your servers local network name or ip address first,

(eg. "http://test-server/your-testing-folder/testform.php"

or

"http://192.168.0.2/your-testing-folder/testform.php"

)



On the other hand if this is a development server on the same machine (ie your own workstation) try using the loopback ip address into the browser address bar,

as; "http://127.0.0.1/your-testing-folder/testform.php"



Instead of tying to browse to the local drive location of;

"c:\apache\www\your-testing-folder\testform.php"



Php is a server-side scripting language so anything you do in a php script has to be processed by the server. It's not like javascript where it can be processed locally.
ce
2006-08-26 12:20:19 UTC
The web server is not executing your PHP file.



Have you uncommented the lines in the Apache configuration file (httpd.conf) that relate to PHP? This is not done by default. The lines look like :



# LoadModule php4_module libexec/httpd/libphp4.so



# AddModule mod_php4.c



Remove the # sign at the beginning of the line to uncomment. Also, look through that file and you'll also see a spot that defines the different file extensions that your server will accept. Make sure .php is in there.



To confirm whether the server is processing the PHP file, make a one line script like this:






phpinfo();



?>



and save it as info.php. Then open this file in your web browser and see if it displays a page of details about your php configuration. If it doesn't, then check your Apache configuration files.





------



Edit: The suggestion of trying it through the 127 ip address is a good idea.



I looked at some of the WAMP packages, and noticed that some include an Apache modules manager that allows you to enable modules.



http://www.wampserver.com/en/index.php



Is this the one you are using?
Kush
2006-08-26 12:15:39 UTC
Pretty weird. I've never tested PHP on localhost, so I'm not sure if that can cause weird problems I'm not aware of.



Everything looks ok, but I don't have all the info. It would be nice if you could link to the full source of the pages, I know there's a limit here.



Stuff I can think of:

-Try the page in another browser

-Make sure the form page is .php even though it doesn't actually have any PHP in it. I've gotten problems having .html post to .php .



The problem I guess could be in register.php, I just don't know.



Good luck!
Jeffrey F
2006-08-26 12:37:15 UTC
Apache doesn't know how to handle the .php extension that is coming to the browser. Apache then tells the browser that .php is something that the browser can't display so it prompts the user to download it.



in your httpd.conf file, add the following and restart the apache server:

AddType application/x-httpd-php .php



This directive tells apache that if the browser requests a .php, stream it to the browser as html.



I hope this helps
Random
2006-08-26 12:12:13 UTC
do you have a php engine installed to interpert the php?



try making a file name test.php



and put the following in it.






echo "Hello World";



?>



All you should see is Hello World.



If you don't.... they you probably don't have a php engine installed.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...