New to PHP

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
drp
Forum Newbie
Posts: 4
Joined: Mon Feb 04, 2008 11:00 am

New to PHP

Post by drp »

Hi Guys,

Im new to PHP and this is my first time on your forum so bear with me.

I have installed Apache, MYSQL and PHP on to a Vista OS, the Apache side of things seems to be working OK but when i try to pull up an PHP document Vista asks me if i want to allow this, then if i want to open or save.
If i click open, it then opens the documents in notepad and shows me the code i have entered.

The PHP document i am trying to use is a simple PHP info doc which in theory should show me the information from my PHP ini file.
I have added code to the loadmodule and Addtype sections of the HTTPD.conf file in Apache which seem to run just fine without error.

If anybody can tell me where i am going wrong or why this is happening i would be most grateful as it is the first piece of PHP scripting i have tried and it seems to not be working for no apparent reason.

Thanks in advance,

drp
User avatar
Zoxive
Forum Regular
Posts: 974
Joined: Fri Apr 01, 2005 4:37 pm
Location: Bay City, Michigan

Re: New to PHP

Post by Zoxive »

First things first, how are you opening the page?

Normally you would go to something like the following:

http://localhost/ or http://127.0.0.1/

http://localhost/mypage.php

On Windows, the server directory is normally where ever you have installed apache.

Ex:
C:/Program Files/Apache/htdocs/
drp
Forum Newbie
Posts: 4
Joined: Mon Feb 04, 2008 11:00 am

Re: New to PHP

Post by drp »

Apache has no problem finding the document, it simply opens it with notepad instead of running the PHP script.

To open the page i goto http://localhost/phpinfo.php.

The file itself is saved as "phpinfo.php".

Sorry if i am not making myself clear, as i said i'm new to PHP.

Thanks for looking at this for me.

drp
User avatar
JAM
DevNet Resident
Posts: 2101
Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:

Re: New to PHP

Post by JAM »

Perhaps a stupid question, but di you restart Apache after you change it's httpd.conf?
Also, adding the below might help? Just a thought...

Code: Select all

<Files *.php>
SetOutputFilter PHP
SetInputFilter PHP
</Files>
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
I'm not that familiar with Apache, but I found it in another .conf. Worth a shot?
drp
Forum Newbie
Posts: 4
Joined: Mon Feb 04, 2008 11:00 am

Re: New to PHP

Post by drp »

Yeah, i restarted Apache after altering the .config file, i'm wondering if it's something to do with either file association (so my PHP files are being opened by notepad), or wether i have screwed up the .config somewhere and PHP files are simply not being parsed by the browser.

It's weird though because i have bought 2 books on the subject and they have given me almost identical instructions, both yielding the same results.

I have also tried both scripting versions for the addtype command (.php and .phps) but neither seem to change the result or solve the issue.

Thanks for your help.

drp
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: New to PHP

Post by califdon »

drp wrote:... or whether i have screwed up the .config somewhere and PHP files are simply not being parsed by the browser.
I think that's it. I've had similar problems on Windows. Don't get discouraged. It will work, but you have to outsmart Microsoft, they don't want you to use open source products! :roll:
drp
Forum Newbie
Posts: 4
Joined: Mon Feb 04, 2008 11:00 am

Re: New to PHP

Post by drp »

Ok, i have added the script given by Jam but to no avail, i have also tried installing firefox and launching it from there with the same results.

I tried to tell the PC to open the file using the browser rather than notepad, This then opened an endless series of windows.
As far as i can tell everything is in order and as it should be but the code is just not behaving the way it should.

I do have a Mac i could install AMP on but i would really rather use the PC.
Any other ideas as to why this might be happening?

Thanks for all your help,

drp
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: New to PHP

Post by Benjamin »

Few things..

Make sure you put the php dll files in the correct place.
Check the apache error log for any errors (including startup errors)
Post your httpd.conf file.
User avatar
JAM
DevNet Resident
Posts: 2101
Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:

Re: New to PHP

Post by JAM »

http://www.wampserver.com/en/ is all-ion-one (well, basicly, for beginners), that might be of interest if you don't want to dwell into deeper settings within the apache, php and mysql settings. You wont learn as much, but you might want to take it one step at a time...

Other ideas is to drop (or move) your httpd.conf in your trashcan, and restart apache. If it starts at all, it's reading from a different source, rather than the one your editing. Might sound stupid, but a thought. i recall having done similiar stupid mistakes to both httpd.conf and php.ini in my days... :banghead:
Post Reply