Jump to content

Recommended Posts

Could someone please tell me what that is and why it is showing up in my page?

 

the page it is showing up on lives in

 

/dir/page_with_error.php

 

I am including a file that lives in

 

/includefile.php

 

with this code..

 

<?php
$array = explode('/', $_SERVER['DOCUMENT_ROOT']);
for($x=1; $x < (count($array) - 1 ) ; $x++){$serverRoot.= '/'.$array[$x];}
include($serverRoot.'/connect.php');  
?>

 

Anyone got an idea??

 

Thanks,

 

Nate

What exactly is the point of the code posted anyway?

 

I have a db class that handles all db communications. I want to use this with all the sites that reside on the server . I placed the file on the root of my webserver, each site lives in a dir named as the site.

 

I use the code I posted to include this file. Since it lives in a directory above the site, I did not want to hard code the path, so I use the explode to create an array with all the pieces of the path.. e.g.

 

the path come out something like /kunden/pages/32432432432432/htdocs/mysite.com

 

then I basically replace the last /XXXX.XXX with /connect.php and my connection class is included from outside the site root.

 

 

or just use notepad to remove it.

 

It does not show in the code at all. Not with notepad or anything.

You could simply use....

 

<?php

$serverRoot = dirname($_SERVER['DOCUMENT_ROOT']) . '../';
include($serverRoot . '/connect.php');
  
?>

 

Gives me the following error

 

Warning:include(/11/d207413455/htdocs..//connect.php) failed to open stream: No such file or directory in

 

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

  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...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.