Help - screen is displaying source code

XML, Perl, Python, and other languages can be discussed here, even if it isn't PHP (We might forgive you).

Moderator: General Moderators

Post Reply
dangerousjohnny
Forum Newbie
Posts: 8
Joined: Thu Nov 13, 2003 12:05 pm

Help - screen is displaying source code

Post by dangerousjohnny »

Hi everyone,
I am fairly new to PHP, but I recently installed Apache and PHP and everything was working fine, but all of a sudden, when I run my perl scripts, the browser just displays the source code. These same scripts worked fine the other day, but now nothing works. help!
Last edited by dangerousjohnny on Thu Nov 13, 2003 12:40 pm, edited 1 time in total.
maniac9
Forum Commoner
Posts: 55
Joined: Fri Aug 01, 2003 12:27 am
Location: Arkansas, USA
Contact:

Post by maniac9 »

maybe i'm lost...but isn't this php?
dangerousjohnny
Forum Newbie
Posts: 8
Joined: Thu Nov 13, 2003 12:05 pm

Post by dangerousjohnny »

Sorry, meant PHP. :oops:
User avatar
DuFF
Forum Contributor
Posts: 495
Joined: Tue Jun 24, 2003 7:49 pm
Location: USA

Post by DuFF »

Can you post the code of an example that is showing source code?
Cruzado_Mainfrm
Forum Contributor
Posts: 346
Joined: Sun Jun 15, 2003 11:22 pm
Location: Miami, FL

Post by Cruzado_Mainfrm »

i don't think he needs to post source code, i think he has somehow misconfigured apache in the httpd.conf file, check that file and look where there php interpreter is aliased, maybe you changed php.exe to another folder, check that too

hope this helps

ps. this is a PHP Code forum, this post should be moved to the General forum
User avatar
scorphus
Forum Regular
Posts: 589
Joined: Fri May 09, 2003 11:53 pm
Location: Belo Horizonte, Brazil
Contact:

Post by scorphus »

dangerousjohnny, let's strip your problem. Please take the time to answer some questions:

• What system are you running?
• Where is your Apache installed?
• What PHP version is installed?
dangerousjohnny
Forum Newbie
Posts: 8
Joined: Thu Nov 13, 2003 12:05 pm

Post by dangerousjohnny »

scorphus wrote:dangerousjohnny, let's strip your problem. Please take the time to answer some questions:

• What system are you running?
• Where is your Apache installed?
• What PHP version is installed?
Windows XP
C:/Program Files/Apache Group/Apache
php version 4.3.3
apache version 1.3.27
User avatar
scorphus
Forum Regular
Posts: 589
Joined: Fri May 09, 2003 11:53 pm
Location: Belo Horizonte, Brazil
Contact:

Post by scorphus »

Ok, now open the file C:\Program Files\Apache Group\Apache2\conf\httpd.conf and look for these lines:

Code: Select all

ScriptAlias /php/ "c:/php/"
Action application/x-httpd-php "/php/php.exe"
AddType application/x-httpd-php .php
Where is your PHP installed to? It must be C:\php\
dangerousjohnny
Forum Newbie
Posts: 8
Joined: Thu Nov 13, 2003 12:05 pm

Post by dangerousjohnny »

scorphus wrote:Ok, now open the file C:\Program Files\Apache Group\Apache2\conf\httpd.conf and look for these lines:

Code: Select all

ScriptAlias /php/ "c:/php/"
Action application/x-httpd-php "/php/php.exe"
AddType application/x-httpd-php .php
Where is your PHP installed to? It must be C:\php\
Yes I have all of that in my httpd.conf and php is installed in c:\php\
I don't know why, it worked last week.
User avatar
scorphus
Forum Regular
Posts: 589
Joined: Fri May 09, 2003 11:53 pm
Location: Belo Horizonte, Brazil
Contact:

Post by scorphus »

Are you sure about the file extensions? Create a new file inside C:\Program Files\Apache Group\Apache2\htdocs, name it test.php and write this:

Code: Select all

<?php
phpinfo();
?>
to it. Point your browser to http://localhost/test.php. What you get?
dangerousjohnny
Forum Newbie
Posts: 8
Joined: Thu Nov 13, 2003 12:05 pm

Post by dangerousjohnny »

scorphus wrote:Are you sure about the file extensions? Create a new file inside C:\Program Files\Apache Group\Apache2\htdocs, name it test.php and write this:

Code: Select all

<?php
phpinfo();
?>
to it. Point your browser to http://localhost/test.php. What you get?
Hey, that worked! Maybe it was because I was using my browser then file->open and selecting the files that it wasn't working. :oops:

Thank you very much!
Paddy
Forum Contributor
Posts: 244
Joined: Wed Jun 11, 2003 8:16 pm
Location: Hobart, Tas, Aussie
Contact:

Post by Paddy »

That is exactly why it wasn't working, not maybe. ;)

With an html file you can just open it locally via the browser. With a php file you need to have php installed and then open it with a http address.

And just for you info. If you want an external computer to look at your php stuff you can swap "localhost" with your IP address. Not part of your problem but if you are new to this you may wanna know that.
User avatar
scorphus
Forum Regular
Posts: 589
Joined: Fri May 09, 2003 11:53 pm
Location: Belo Horizonte, Brazil
Contact:

Post by scorphus »

You're welcome, I'm glad it works! Remeber all PHP execution is made by the webserver. So to see how your PHP pages are 'running' you have to request them from the webserver (Apache via HTTP, http://localhost in your case) not to the file-system (Windows' file-system via file->open). Do this last when going to edit them...

Well, it's all nice now :) have fun!

Regards,
Scorphus.
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Moved to miscellaneous.

Mac
Post Reply