$path_info

software development

#1

Ok, well, I’m trying to get an old script of mine up and running but it uses $PATH_INFO to call all its variables from the url and I was just wondering if I have to do something to get this working because at the moment the variable just does not call anything at all.

The file can be found at http://www.vanro.otakuexperiment.com/includes/urlarray.php

And the source code(Note, there are no dots in the actual files <b.r>):

<?php global $filename, $location, $section, $item, $name, $page; $var_array = explode("/",$PATH_INFO); $filename = $var_array[0]; $location = $var_array[1]; $section = $var_array[2]; $item = $var_array[3]; $page = $var_array[4]; echo $filename; echo ""; echo $location; echo ""; echo $section; echo ""; echo $item; echo ""; echo $page; echo ""; echo "lol"; echo ""; echo $_GET["parameters"]; echo ""; echo $PATH_INFO; ?>

Any help would be appreciated


#2

I don’t think the PATH_INFO environment variable is used in the DreamHost setup; however, there are all sorts of ways to access information from a URL. I recommend that you study the PHP predefined variables for your specific needs.


Simon Jessey | Keystone Websites
Save $97 on yearly plans with promo code [color=#CC0000]SCJESSEY97[/color]


#3

Heh, thanks, I had been there but wasn’t sure what to do/how relevant it was.


#4

What is your script trying to do, exactly? It almost looks as if you just need to use parse_url(). If you can provide more information, I’d be glad to help.


Simon Jessey | Keystone Websites
Save $97 on yearly plans with promo code [color=#CC0000]SCJESSEY97[/color]


#5

Well, It was pretty simple, basically in the url:
http://www.vanro.otakuexperiment.com/index.php/tickets/list/
it would get index.php,tickets,list and put them all into there own variables as displayed in the code above.
So then if $location = tickets then it would know to open the ticket section of the site and if $section = list then it would know to list all the tickets.
All I really need is some new method for getting the same type of url and storing it into variables again since this is all done in a single function file.

I guess what I really just need is the variable that the current url is stored in.


#6

Ok, thanks for the help jessey, I got it finally, for anybody that might stumble upon this forum looking for similar help here’s my newer code:

global $filename, $location, $section, $item, $name, $page;
$var_array = explode("/",$_SERVER[“REQUEST_URI”]);
$filename = $var_array[1];
$location = $var_array[2];
$section = $var_array[3];
$item = $var_array[4];
$page = $var_array[5];


#7

I’m glad you worked it out. :slight_smile:


Simon Jessey | Keystone Websites
Save $97 on yearly plans with promo code [color=#CC0000]SCJESSEY97[/color]


#8

It seems to work okay for me. With PHP 5, at least–haven’t tried 4.

I just threw up a phpinfo() file, like php-info.php for example:

<?php phpinfo(); ?>

Then accessed it with something like example.com/php-info.php/asdf, which showed /asdf as the value for $_SERVER[‘PATH_INFO’].


:stuck_out_tongue: Save up to $96 at Dreamhost with ALMOST97 promo code (I get $1).
Or save $97 with THEFULL97.


#9

[quote]I just threw up a phpinfo() file, like php-info.php for example:

[/quote]

Just try it; gotta like that.

This wiki page, with a record setting long name, points to assorted combinations of Apache and PHP versions, for more testing.

[quote]threw up

[/quote]

Uuurp! :wink:


They recently hired more support help.
Tip me (and DreamHost gets 5%+$0.30)


#10

I checked a couple of domains before I posted, and neither had a value for PATH_INFO. I’ve now checked ALL my domains, and it appears that some have it and some don’t. None of my PHP4 domains even list PATH_INFO, either as an environment variable or as a server variable.


Simon Jessey | Keystone Websites
Save $97 on yearly plans with promo code [color=#CC0000]SCJESSEY97[/color]