Re: 'nested conditional' that can identify parent page?



Alan Jones wrote:
On Sun, 13 May 2007 09:41:17 -0500, Jerry Stuckle
<jstucklex@xxxxxxxxxxxxx> wrote:

Alan,

$_SERVER['REQUEST_URI'] does give the uri used to fetch the page. I'm not sure what you mean by 'child' file. Are you using frames? Maybe if you post the code you're using (including that in the 'parent' and 'child' pages) it will be more clear.

Thanks for helping me. :)

To isolate the process, I have recreated the scenario using new
files, file names, and a new folder called 'test'.

http://jalanjones.com/index2.php

: Inside of index2.php is...

<html><head><title></title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
</head><body>

<p>This sentence is in the index2.php file.</p>

<p><?php include('http://jalanjones.com/test/content.php');?></p>

<p>Why is there a numeral one (1) at the end? (scratching
head)<br><br></p>

</body></html>

: ...and inside of /test/content.php is...

<html><head><title></title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
</head><body>
<table cellpadding="10" style="border:1px solid #333333"><tr><td>

<p><br>This table is in the content.php 'include' file.</p>

<p>REQUEST_URI result:&nbsp;&nbsp;&nbsp;<b>
<?php echo($_SERVER['REQUEST_URI']);?></b></p>

<p>The result (/test/content.php) is the name of the include/child
file, not the parent page; the URL.</p>

<p>Below is phpinfo() run from inside the include file. Please see
the PHP Variables section...<br><br></p>

<?php echo phpinfo();?>

</table></tr></td>
</body></html>

Can anyone identify the culprit? Again, I am very new to PHP so it
is probably something only a clueless newb would do. :D

And as Schraalhans indicated, commands which relate to the underlying filesystem (i.e. link, fopen, include, etc.) reference the file system directly. So if you use absolute paths (beginning with '/'), it is the root directory of the file system. But your host has limited you so all you can access are files in /hom/httpd/vhosts/jalanjones.com/httpdocs and /tmp.

Thanks, I hope to avoid using link().


This is working normally. When you said:

<?php include('http://jalanjones.com/test/content.php');?>

This resulted in another call to the server to fetch test/content.php. So the URL in there will be "test/content.php". The only difference here is you included it from the server side instead of the client side - but when the http: request reaches the server, the server neither knows nor cares about the origin. The PHP file is executed and the results returned to index2.php, where they are displayed.

Now, if you would have instead done something like:

<?php include($_SERVER['DOCUMENT_ROOT'] . '/test/content.php');?>

This would have gone directly to the file system and included the file without an additional call to Apache. The file would have been included, the code executed and the results displayed.

Do you see the difference between the two?


--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@xxxxxxxxxxxxx
==================
.



Relevant Pages

  • Re: PHP Instalation problems. Browser doesnt know what to do
    ... This is loaded and run as a local server (for class ... PHP 5.2.0 from php-5.2.0-win32-installer.msi ... # configuration directives that give the server its instructions. ...
    (comp.lang.php)
  • Re: PHP Instalation problems. Browser doesnt know what to do
    ... This is loaded and run as a local server (for class ... PHP 5.2.0 from php-5.2.0-win32-installer.msi ... # configuration directives that give the server its instructions. ...
    (comp.lang.php)
  • Re: write with cURL
    ... execute permissions. ... This is assuming that the PHP script runs ... of potential security risks from other users on the same server. ... Apache as the global web server user and thus needs world write ...
    (alt.php)
  • mysqli error?
    ... I'm just setting up my php enviroment and I typed in a simple script ... # configuration directives that give the server its instructions. ...
    (comp.lang.php)
  • Re: write with cURL
    ... execute permissions. ... This is assuming that the PHP script runs ... of potential security risks from other users on the same server. ... web server itself is part of the group. ...
    (alt.php)