Newbie PHP question

software development

#1

I recently moved my site to Dreamhost, and am having trouble getting one page to work.

Here’s how the page should look (on the old host’s server):
http://wcpe.org/who_am_i/

Here’s what i’m getting on the Dreamhost-hosted page:
http://theclassicalstation.org/who_am_i/

I don’t understand the error messages. Can someone help?

I appreciate any advice you can give… I’ve inherited this page, and know nothing about php.


The index page is set up with this code in the middle:

The include.php3 file looks like this:
#!/usr/local/lib/php

<? require("http://TheClassicalStation.org/who_am_i/random/randex.php3"); ?>

Then the randex.php3 page has the php code, beginning with this line:
#!/usr/local/bin/php


#2

The error message URL file-access is disabled in the server configuration is telling you that DreamHost have chosen to disable URL file access for security reasons. Your include functions presumably have paths beginning with http://. You need to change those to a local path.

So instead of this:<? require("http://TheClassicalStation.org/who_am_i/random/randex.php3"); ?>Use this:<?php require($_SERVER['DOCUMENT_ROOT']."/who_am_i/random/randex.php3"); ?>You can read more about this issue on this page of the DreamHost Wiki.


Simon Jessey
Keystone Websites | si-blog


#3

wow, thank you for the superfast response! you rock!

i used the code you suggested, and now the php code itself is appearing in the page. (in other words, the code is not running, it’s being printed.) suggestions?

http://theclassicalstation.org/who_am_i/


#4

It looks like some of your PHP is not being treated as such. It may (or may not) have something to do with your use of the .php3 extension - I really don’t know.

Incidentally, I’ve added more content to that wiki article to help explain what is happening.


Simon Jessey
Keystone Websites | si-blog


#5

Looking at your page again, it may be that you’ve left <?php off the front of the code. I can see the closing tag.

Edit: Actually, it looks like you have the page saved as an .shtml file. If you want the PHP to be processed, it must have a .php extension.


Simon Jessey
Keystone Websites | si-blog


#6

thank you so much for hanging with me on this…

one of the many includes on the .shtml page is this:

the include.php file looks like this (in its entirety):

#!/usr/local/bin/php

<?php require($_SERVER['DOCUMENT_ROOT']."/who_am_i/random/randex.php"); ?>

it looks like the person who originally programmed this page used an include to get a php script working. because i don’t know php, i can’t say whether this is the best way to go about this or not.


#7

You can include PHP files via SSI and have the script output displayed on the .shtml page. I’m doing it myself on one site.

The missing opening PHP tag appears to be the problem. Loading the included file directly just displays the script contents sans opening tag.


If you want useful replies, ask smart questions.


#8

aha!! i got it working!!

it was a combination of removing “#!/usr/local/bin/php” from the top of the script and replacing it with “<?php”

AND

inserting this very valuable code [$_SERVER[‘DOCUMENT_ROOT’].] into the php script itself

many thanks for all your help!


#9

We aim to please :slight_smile:


Simon Jessey
Keystone Websites | si-blog