newbie PHP question

newbie PHP question

Posted by: xtaxta
Posted on: 2005-05-20 07:58:00

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


Re: newbie PHP question

Posted by: scjessey
Posted on: 2005-05-20 08:18:00

In reply to:

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


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.

Re: newbie PHP question

Posted by: xtaxta
Posted on: 2005-05-20 08:26:00

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/

Re: newbie PHP question

Posted by: scjessey
Posted on: 2005-05-20 08:42:00

In reply to:

now the php code itself is appearing in the page


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.

Re: newbie PHP question

Posted by: scjessey
Posted on: 2005-05-20 08:45:00

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.

Re: newbie PHP question

Posted by: xtaxta
Posted on: 2005-05-20 09:59:00

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.

Re: newbie PHP question

Posted by: kchrist
Posted on: 2005-05-20 10:03:00

You can include PHP files via SSI <!--#include --> 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.

Re: newbie PHP question

Posted by: xtaxta
Posted on: 2005-05-20 10:22:00

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!


Re: newbie PHP question

Posted by: scjessey
Posted on: 2005-05-20 10:24:00

In reply to:

many thanks for all your help!


We aim to please smile

Tags: phpdreamhosterror messagesorgusrnewbieliblocalindexhttphelpappreciate