Super Sam Posted February 20, 2006 Share Posted February 20, 2006 I'm having a problem with .php files - every time I try to view them in an Internet browser (I've tried Internet Explorer and Firefox), it asks me to download it (with MIME type "application/octec" or similar), rather then viewing it. I can see .php files on the Internet fine, but locally (such as C:/file.php), I'm asked whether I want to download or open the file (choosing to open the file in IE or Firefox results in the download or open message again). I presume this is because my .php associations have been overwritten at some point.I've created test files (with plain text, HTML code, and PHP code) with .php extensions, and all of them suffer the same problem, whether I access them from my hard drive (C:/), localhost or my IP. Any ideas what the problem could be? Quote Link to comment Share on other sites More sharing options...
zendak Posted February 20, 2006 Share Posted February 20, 2006 Have you set up a web server locally? If you have, you should browse to your php pages a la [b]http://localhost/myfile.php[/b] , your php will be processed by the server and generate a web poage in the expected manner. Of course, MIME types should be set up properly on the server, and make sure that a PHP interpreter is running :)If you haven't set up a web server or if you browse to the file like [b]file:///c:/file.php[/b], your operating system will want to know what to do with the file ("open", "save as" etc), as the php is not being processed by the interpreter. That's quite normal. Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted February 20, 2006 Share Posted February 20, 2006 Becuase PHP is a server sided programming language it can only be run on a server. You can run your php scripts locally as zendak mentioned. You need to have a server installed on your computer which you can do for free by getting:- Apache (the server)- PHP (the interpretor, the program that parses your php scripts)- MySQL (optional, if you dont want to use a database).You can install these manually which is straight forward you can install a package called WAMP or XAMPP both are free. Quote Link to comment Share on other sites More sharing options...
Super Sam Posted February 21, 2006 Author Share Posted February 21, 2006 I have PHP, MySQL and IIS 5.1. It still doesn't work, whether on file:///C:/index.php, [a href=\"http://localhost:444/index.php\" target=\"_blank\"]http://localhost:444/index.php[/a] or http://(ip address):444/index.php. The odd thing is that it used to work a week or so ago, then it just stopped working. Quote Link to comment Share on other sites More sharing options...
jcavard Posted February 21, 2006 Share Posted February 21, 2006 i would try to download xampp at apachefriends.com or easyPHP.org and what if you try only [a href=\"http://localhost/index.php?\" target=\"_blank\"]http://localhost/index.php?[/a]? without the port ... also, I think localhost is port 80 (well, at least for me) Quote Link to comment Share on other sites More sharing options...
Super Sam Posted February 22, 2006 Author Share Posted February 22, 2006 I changed the port number back to the default, and now for [a href=\"http://ipaddress/index.php\" target=\"_blank\"]http://ipaddress/index.php[/a] and [a href=\"http://localhost/index.php\" target=\"_blank\"]http://localhost/index.php[/a] it says the following:[code]Error in CGI ApplicationThe specified CGI application misbehaved by not returning a complete set of HTTP headers. The headers it did return are:[/code]Also, I don't have any MIME types set up on the server for .php. Quote Link to comment Share on other sites More sharing options...
Super Sam Posted March 10, 2006 Author Share Posted March 10, 2006 Okay, I've re-installed everything from scratch. I've got the latest version of Apache and PHP installed. Now, when I browse to a php file from localhost (or my IP), it doesn't ask me to download the file, but instead it just displays the code.[a href=\"http://220.237.65.152/One80%20Wiki/index.php\" target=\"_blank\"]Example Page[/a]For me, it just shows up as the source code. Does anybody else experience this and/or is there way for me to fix it? Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted March 10, 2006 Share Posted March 10, 2006 Have you configured Apache correctly? Ie have added the following line in to the httpd.conf file:[code]AddType application/x-httpd-php .php[/code]How you setup Apache to parse php files as a Apache module (which I recommend) or a ScriptAlias (CGI) Quote Link to comment Share on other sites More sharing options...
Super Sam Posted March 11, 2006 Author Share Posted March 11, 2006 I did what you said, but now I'm getting the first problem - it asks me to download the file.Then, in a step I should've done way earlier, I followed the link in your sig to Installing PHP and Apache. The problem is now fixed. (whacks head)Thanks for everybody who tried to help. :-) Quote Link to comment Share on other sites More sharing options...
txmedic03 Posted March 11, 2006 Share Posted March 11, 2006 PHP is not a server side programming language, it is a server-side scripting language. A language which can be run by command-line interpreter on the local system without the use of an httpd. All you have to do is configure the system to associate the .php or whatever other extension you want with the php interpreter. I would not recommend this, but it is none the less possible. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.