why does the index.php file display the code?

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

adneg
Forum Newbie
Posts: 13
Joined: Wed May 21, 2003 11:20 am

why does the index.php file display the code?

Post by adneg »

:cry: I have installed PHP and can see the phpinfo(), but when I try to view my development website all i see is the code in the index.php.


My virtual host is setup correctly, mysql is running and also Apache. I have this added AddType application/x-httpd-php .php in the http.conf file.


I am really lost with this one
User avatar
Wayne Herbert
Forum Commoner
Posts: 34
Joined: Tue Apr 29, 2003 3:13 pm
Location: Houston, Texas

Post by Wayne Herbert »

If you can see the phpinfo page then that suggests that you are set up correctly for php.

Are you loading your website via a file id or a URL? The first won't work, the second will.

If all above is correct, post the code.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

and check wether the index.php script uses short tags <? ... ?>
They might be disabled.
http://www.php.net/manual/en/configurat ... t-open-tag
adneg
Forum Newbie
Posts: 13
Joined: Wed May 21, 2003 11:20 am

Post by adneg »

the code is:

<?php header("Location: http://fletcher.co.uk/site/site.php/hom ... newsession"); ?>


Calling the script using http://www.fletcher.co.uk

Volka as you can see the index.php uses <? ?>, i have checked and it is on.
Last edited by adneg on Thu May 22, 2003 11:28 am, edited 1 time in total.
User avatar
liljester
Forum Contributor
Posts: 400
Joined: Tue May 20, 2003 4:49 pm

Post by liljester »

"index.osp"? did you configure apache so that it would execute .osp files?
adneg
Forum Newbie
Posts: 13
Joined: Wed May 21, 2003 11:20 am

Post by adneg »

no i did not. What is the best way to do this? hopefully without breaking it.
User avatar
liljester
Forum Contributor
Posts: 400
Joined: Tue May 20, 2003 4:49 pm

Post by liljester »

did you use the .osp file extension on purpose? why not just use index.php instead of index.osp?
adneg
Forum Newbie
Posts: 13
Joined: Wed May 21, 2003 11:20 am

Post by adneg »

The site was designed by a web design company so I do not know why they used the .osp.

I am trying to have a copy of the site at home so that I can do development work on it before putting it on the live site.

is there anybody who can point me in the right direction for what I have to do?
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

I have this added AddType application/x-httpd-php .php in the http.conf file.
This told apache that files with the extension .php are of the mimetype application/x-httpd-php (that is handled by the php module).
Now you want to tell apache that files with the extension .osp are of the same mimetype...

(there's no way of asking the designer "why .osp?" ?)


http://httpd.apache.org/docs-2.0/mod/mo ... ml#addtype
adneg
Forum Newbie
Posts: 13
Joined: Wed May 21, 2003 11:20 am

Post by adneg »

Ok, I will add the line
AddType application/x-httpd-osp .osp?

and hope it works
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

you don't want to tell apache the files are of the mimetype application/x-httpd-osp because mod_php doesn't handle it.
But it handles application/x-httpd-php for as many extensions as you like ;)
AddType MIME-type extension [extension] ...
this tells apache that whenever it hits a file with the extension extension it should treat the file as mimetype MIME-type. So it will search for a handler that will serve MIME-type.
mod_php registered itself as handler for application/x-httpd-php
adneg
Forum Newbie
Posts: 13
Joined: Wed May 21, 2003 11:20 am

Post by adneg »

There is something not right here.

I added the line and I now get 500 internal server error. Just when I think I am getting there.

I wish this was simple!!
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

only replace
AddType application/x-httpd-php .php
by

Code: Select all

AddType application/x-httpd-php .php .osp
in your httpd.conf
adneg
Forum Newbie
Posts: 13
Joined: Wed May 21, 2003 11:20 am

Post by adneg »

I finally got round to doing that. The php code is now being read but, i get the 404 not found page.

I am getting there but slowly.
qartis
Forum Contributor
Posts: 271
Joined: Sat Dec 14, 2002 4:43 pm
Location: BC, Canada
Contact:

Post by qartis »

Create test.osp, and fill it with

Code: Select all

<?php
$foo = "bar";
echo $foo;
?>

And call that script directly from a browser. Post the output here.
Post Reply