473,586 Members | 2,683 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problems including a file referenced from SERVER['DOCUMENT_ROOT']

Why does this find the file:

<img
src="<?=$_SERVE R['DOCUMENT_ROOT']?>/images/viessmann_heade r_logo.gif">

But this does not?

$right_content =
$_SERVER['DOCUMENT_ROOT']."includes/content/content.php";

include $right_content;

Regards

Marc

Dec 28 '06 #1
4 2388
Rik
monomaniac21 wrote:
Why does this find the file:

<img
src="<?=$_SERVE R['DOCUMENT_ROOT']?>/images/viessmann_heade r_logo.gif">

But this does not?

$right_content =
$_SERVER['DOCUMENT_ROOT']."includes/content/content.php";

include $right_content;
Perhaps:
$_SERVER['DOCUMENT_ROOT']."/includes/content/content.php";

Note the extra slash.
--
Rik Wasmus
Dec 28 '06 #2
sorry that was typo document root contains the a forward slash
Rik wrote:
monomaniac21 wrote:
Why does this find the file:

<img
src="<?=$_SERVE R['DOCUMENT_ROOT']?>/images/viessmann_heade r_logo.gif">

But this does not?

$right_content =
$_SERVER['DOCUMENT_ROOT']."includes/content/content.php";

include $right_content;

Perhaps:
$_SERVER['DOCUMENT_ROOT']."/includes/content/content.php";

Note the extra slash.
--
Rik Wasmus
Dec 28 '06 #3
..oO(monomaniac 21)
>Why does this find the file:

<img
src="<?=$_SERV ER['DOCUMENT_ROOT']?>/images/viessmann_heade r_logo.gif">
I really doubt that this works. Is $_SERVER['DOCUMENT_ROOT'] set at all?
Is error_reporting set to E_ALL? Why do you use unreliable short open
tags?

Micha
Dec 28 '06 #4
Rik
monomaniac21 wrote:
Rik wrote:
>monomaniac21 wrote:
>>Why does this find the file:

<img
src="<?=$_SER VER['DOCUMENT_ROOT']?>/images/viessmann_heade r_logo.gif">

But this does not?

$right_conten t =
$_SERVER['DOCUMENT_ROOT']."includes/content/content.php";

include $right_content;

Perhaps:
$_SERVER['DOCUMENT_ROOT']."/includes/content/content.php";

(topposting fixed)
sorry that was typo document root contains the a forward slash
Well then:
ini_set('displa y_errors',1);
error_reporting (E_ALL);
$right_content = $_SERVER['DOCUMENT_ROOT']."includes/content/content.php";
include($right_ content) or die ("File $right_content not found");

And check wether you really can find it in that particular dir manually...

Micheal Fesser also makes a good point:
<img src="<?=$_SERVE R['DOCUMENT_ROOT']?>/images/viessmann_heade r_logo.gif">

Should not work, or only locally, as you document root is not visible to
others, only to yourself. It should fail on every computer except your own,
unless indeed $_SERVER['DOCUMENT_ROOT'] is not set.
--
Rik Wasmus
Dec 28 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2697
by: Rick | last post by:
I am using dynamic vhost on my apache development server (conf at end of msg). I am using $_SERVER in the sites I am working on, which, as you may have guessed isnt giving me the full path of the vhosts web root folder (Its returning the value as set in my main apache conf file as it should) Is there a way to get the full path to the web...
8
2976
by: jerrygarciuh | last post by:
Hello, If you have the whole server path for a file is there a canonical way to get the path from document root for that file so that you can present the file ina browser or for download? Check $_SERVER and parse the path? My thought is that given OS diversity and individual server differences (eg www vs public_html vs htdocs) that...
4
2794
by: Mxsmanic | last post by:
The require() I'm using in a PHP script has stopped working after I moved from PHP4 and Apache 1.3.x to PHP5 and Apache 2.x. Now I get messages like this: Warning: main(/includes/ReloadScript.html) : failed to open stream: No such file or directory in /usr/local/www/htdocs/main/AOLCompression.php on line 14 Fatal error: main() : Failed...
5
5446
by: Dave Smithz | last post by:
Hi There, I have a PHP script that sends an email with attachment and works great when provided the path to the file to send. However this file needs to be on the same server as the script. I want to develop a webpage where people can send attachments that are stored on their local PC.
6
2468
by: micha | last post by:
suppose i have 3 files: script.php somedir/include.php somedir/config.php 1. script.php includes include.php 2. include.php includes config.php, so the structure looks like a cascade now if i include config.php (without path) from include.php the script
5
1368
by: julian_m | last post by:
<? //file test.php phpinfo(); $filename = "test.php"; //it does not work $filename = $_SERVER."/home/ke000067/public_html/test.php"; //it does not work
3
6506
by: kirke | last post by:
I want to save output file on server. (same folder) I have no idea how can I assign path. can i just use $book->saveas("/final.xls"); Thx.
17
1683
by: Paul | last post by:
On my development computer, I have virtual named host set up, like www.site1.lab. When I upload those to my web site for customer review under mywebsite.com/clients/site1/ it throws some of the source file references off and it does not work properly. My references are like: require_once($_SERVER."/utility/top.php");
13
2015
by: Adhal | last post by:
Hi, How can I stop hotlinking to a specific file, and I want it to redirect it to a PHP link so I can monitor the number of downloads. Here is my site with the download page: http://www.adhal.org/software/downloads.htm And here is softpedia directly connecting to my file and bypassing the counter php....
0
7911
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8200
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8338
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7954
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6610
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5710
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3864
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1448
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1179
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.