Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PATH_INFO not found

Status
Not open for further replies.

kaeserea

Programmer
Feb 26, 2003
164
0
0
DE
Dear all,

I use PHP 5.3.1 on an IIS Server.

I'd like to use $GLOABALS["PATH_INFO"] which still works in PHP 5 although it is deprecated. In the php-ini file it turned on the register_globals option. So from PHP's point of view it should work.

Nevertheless I get the error "Undefined index: PATH_INFO". So the Path Info is not accessible for PHP. I guess the problem is at the IIS. I can change the settings there, yet I don't know where to turn the Path_info on.

Can anybody help?

Best wishes
Eva
 
1. You have a typo in your variable name, its $GLOBALS not GLO[red]A[/red]BALS.

Assuming that's just a typo here and in your actual code we can move on.

You don't tell us where you are setting the variable $PATH_INFO?

$GLOBALS just contains variables defined in the global scope.

If you are wanting the variable returned by the server, then that is located in $_SERVER['PATH_INFO']. the $_SERVER array is already global so you can access it like that.

If you are setting a value in a form for instance and want that translated into the variable (seeing as you have set register_globals to On which is a big security risk), then your form element needs to have the name PATH_INFO.

Also did you restart the web server after changing the register_globlas setting in the php.ini?

Printing out the contents of the the $GLOBALS array may also help:

Code:
echo "<pre>";
print_r($GLOBALS);
echo "</pre>";







----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
And also PATH_INFO may or may not actually exist in $_SERVER as it is reliant on the client.

So its possible it just doesn't exist because the clientyou use just doesn't send it.

----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Their is a function in PHP called phpinfo()

This function when added to a page will display all of the PHP environment information. This will come in handy for you as you can see you php.ini setting and the values in the $_SERVER and $_ENV arrays. It also prints a lot of other useful environment information. I would not expose this to the end users in any way but I find it handy when researching server side issues.

Alan
 
Dear all,

the problem is that path_info is not sent. I don't get it with $GLOBALS["PATH_INFO"] neither with $_SERVER["PATH_INFO"]

Do you knwo where I should activate the sending of path info?

Best regards
Eva
 
Hi

Eva said:
Do you knwo where I should activate the sending of path info?
[tt]PATH_INFO[/tt] is never sent anywhere. It is an environment variable set by the web server.

In case that your request has a [tt]PATH_INFO[/tt] part and [tt]$_SERVER['PATH_INFO'][/tt] is unset, your problem is probably not related to PHP. Please post your question in forum41.

Feherke.
 
Dear all,

the problem is that path_info is not sent. I don't get it with $GLOBALS["PATH_INFO"] neither with $_SERVER["PATH_INFO"]

Do you knwo where I should activate the sending of path info?

Best regards
Eva

Make a test page and put a call to the phpinfo() function I mentioned above. It will show you your settings and you may find your path in another location. If its not displayed at that point its a server setup issue.

Alan
 
As I said, the variable may or may not be present, because its not populated. You can't do anything to populate if its not. Its up to the browser.

PHP.net Manual said:
$_SERVER is an array containing information such as headers, paths, and script locations. [red]The entries in this array are created by the web server. There is no guarantee that every web server will provide any of these; servers may omit some, or provide others not listed here[/red]. That said, a large number of these variables are accounted for in the » CGI 1.1 specification, so you should be able to expect those.

PHP.net Manual said:
'PATH_INFO'
Contains any [red]client-provided[/red] pathname information trailing the actual script filename but preceding the query string, if available. For instance, if the current script was accessed via the URL then $_SERVER['PATH_INFO'] would contain /some/stuff.

That means if your client (i.e. Browser) does not send it, the only thing you can do is change Browsers and hope a different browser sends that information.
And there's no guarantee that every browser used to access the page in question will send it.

In short you should not depend on its existence. If its there you may use it, but there's no guarantee it will be there.

----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Hi

Phil said:
And there's no guarantee that every browser used to access the page in question will send it.
As the browser has no access to the file system on the server, it has no idea where the [tt]SCRIPT_NAME[/tt] ends and the [tt]PATH_INFO[/tt] begins. Only the web server can know that, so only depends on the web server.

Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top