Jump to content

Php $_server Question.


dawilson

Recommended Posts

I've moving my domains from another server and find that one of my trivial PHP scripts is generating an error. Can anyone tell me what's up with this and how to correct the problem? I would rather not hardcoded the document root directory but will do this if necessary. The script generates a file modification timestamp and is:

 

<?PHP

echo "Page was last modified on: " . date ("F d Y H:i:s.", filemtime($_SERVER['DOCUMENT_ROOT'].$_SERVER['PHP_SELF']));

?>

 

It generates error:

 

filemtime(): Stat failed for /usr/local/apache/htdocs/~fourcc/intro.php (errno=2 - No such file or directory) in /home/fourcc/public_html/intro.php on line 264.

 

where intro.php is in my public_html directory and is the file which contains the script. It almost looks as if $_SERVER['DOCUMENT_ROOT'] is returning the wrong path?

 

Thanks in advance for any suggestions.

 

Regards,

 

Dave Wilson

Link to comment
Share on other sites

Don,

 

I'll give that a shot but I now suspect some transient effect related to running the script too soon after creating the account and uploading files. Trying to load the page now yields different and bigger problems (something to do with open_basedir apparently). Please could you let me know what the absolute path to a file in my public_html directory is so that I can fix the new problem? Come to think of it, if this info is somewhere else in the support section, I'd love to know where - I searched but couldn't find it.

 

Thanks again,

 

Dave

Link to comment
Share on other sites

Still no luck, I'm afraid. I posted as simple a page as I could which contains just the script and it still fails the same way even though the file it refers to seems to be there. You can find this at http://72.9.232.146/~fourcc/404.php. Can anyone offer any suggestions?

 

Thanks,

 

Dave

Link to comment
Share on other sites

Hi,

 

The problem is that you are trying to get it to work before the domain name has propagated. You can do it, but you need to modify things a little. Do you need to get it working before propagation? (you will have to reset it after the domain name has propagated).

Link to comment
Share on other sites

Andy,

 

I'm trying to ensure that all my sites are moved correctly prior to updating DNS. In the cases of all other PHP sites, I have seen no problems as long as I remember to set the base URL to http://72.9.232.146/~<userid> temporarily (I will switch it back once I update DNS). In this particular case, the PHP is not critical to the site operation so, assuming you reckon I won't have a problem (a PHP error displayed on each page is not acceptable!), I'll go ahead and update DNS then keep my fingers crossed that everything works OK once the change has rippled through.

 

Thanks,

 

Dave

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...