473,398 Members | 2,125 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

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

Why does this find the file:

<img
src="<?=$_SERVER['DOCUMENT_ROOT']?>/images/viessmann_header_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 2380
Rik
monomaniac21 wrote:
Why does this find the file:

<img
src="<?=$_SERVER['DOCUMENT_ROOT']?>/images/viessmann_header_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="<?=$_SERVER['DOCUMENT_ROOT']?>/images/viessmann_header_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(monomaniac21)
>Why does this find the file:

<img
src="<?=$_SERVER['DOCUMENT_ROOT']?>/images/viessmann_header_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="<?=$_SERVER['DOCUMENT_ROOT']?>/images/viessmann_header_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";

(topposting fixed)
sorry that was typo document root contains the a forward slash
Well then:
ini_set('display_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="<?=$_SERVER['DOCUMENT_ROOT']?>/images/viessmann_header_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
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...
8
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...
4
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:...
5
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. ...
6
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...
5
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
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
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...
13
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:...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...
0
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...

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.