SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Evangelist
    Join Date
    Oct 2000
    Posts
    430
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    I'm having a few problems getting this to work. Basically I want to pass a string of variables to a script, which then passess the string of variables on again as variables - if your confused here's an example:

    this gets passed to script1:

    /script1.php?A=1&B=variable1?nextpassvariable=2&next2passvariable=3

    so when this is passed to script1

    I want B="variable1?nextpassvariable=2&next2passvariable=3"

    Which is then passed on again via a URL to the next script, and not to be broken down prior to this as follows:

    B=variable1
    nextpassvariable=2
    next2passvariable=3

    I believe the solution lies in URL encoding, but am unsure on how this works.



  2. #2
    Serial Publisher silver trophy aspen's Avatar
    Join Date
    Aug 1999
    Location
    East Lansing, MI USA
    Posts
    12,937
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I dont know if this is what you're looking for, but give it a try, this doesn't use a query string.

    $url_array = explode("/",$PATH_INFO);

    $id=$url_array[1];
    $Num=$url_array[2];

    And when using that your url would look like this:

    http://www.site.com/script.php3/mobydick/12

    Search engines will indexed that page even though its dynamic.



    Chris Beasley - I publish content and ecommerce sites.
    Featured Article: Free Comprehensive SEO Guide
    My Guide to Building a Successful Website
    My Blog|My Webmaster Forums

  3. #3
    SitePoint Evangelist
    Join Date
    Oct 2000
    Posts
    430
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    where do you get $PATH_INFO from - I do not believe there is any such pre-defined variable? I tried to echo it an got nothing.

    Anyway, I have an idea for a solution, if I can get hold of the 'full page URL' as a variable.

    Is there an easy way to do this? - a way that would include the exact URL as written in the html of the page being linked from - including all variables, encoded charactors etc

    I tried $PHP_SELF (Which is probably what you need instead of $PATH_INFO by the way) and this only holds the file name relative to the root and does not include any passed variables.

    Any solutions?

  4. #4
    Serial Publisher silver trophy aspen's Avatar
    Join Date
    Aug 1999
    Location
    East Lansing, MI USA
    Posts
    12,937
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    path info is a variable, why it doesn't work for you I dont know, but I copied that directly from my site and it works as intended.
    Chris Beasley - I publish content and ecommerce sites.
    Featured Article: Free Comprehensive SEO Guide
    My Guide to Building a Successful Website
    My Blog|My Webmaster Forums

  5. #5
    Grumpy Mole Man Skunk's Avatar
    Join Date
    Jan 2001
    Location
    Lawrence, Kansas
    Posts
    2,066
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try this:

    $HTTP_SERVER_VARS["REQUEST_URI"];

    Also, remember that if you are calling it from within a function you won't get anything as the variable will be outside the 'scope' of the function. If you want to access it from a function you will need to use the gloabl command at the beginning of the function i.e:
    Code:
    global $PATH_INFO;

  6. #6
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    $PATH_INFO is indeed a variable, although I can't seem to get it to print on my screen right now, the only time I ever needed it is when running in CGI mode, you would use it instead of $PHP_SELF becuase $PHP_SELF points to the php interpreter(php.exe) on Windows and you want the script path, $PATH_INFO gives it to you. Maybe its gone in PHP4.0.4 aspen what version and what platform you running? There is one variable called $QUERY_STRING the holds the value of everything after the ? in a url so

    /script1.php?A=1&B=variable1&nextpassvariable=2&next2passvariable=3


    if you printed $QUERY_STRING after this page loaded you would get

    A=1&B=variable1&nextpassvariable=2&next2passvariable=3


    Also Chilliboy notice how you have tow ? marks in your query string you can only have 1 and the rest should be &
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  7. #7
    Serial Publisher silver trophy aspen's Avatar
    Join Date
    Aug 1999
    Location
    East Lansing, MI USA
    Posts
    12,937
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    redhat and php3
    Chris Beasley - I publish content and ecommerce sites.
    Featured Article: Free Comprehensive SEO Guide
    My Guide to Building a Successful Website
    My Blog|My Webmaster Forums

  8. #8
    SitePoint Evangelist
    Join Date
    Oct 2000
    Posts
    430
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I guess from what you say that $PATH_INFO must be php3 and not php4. Not found within the pre-defined variables in the manual:

    http://www.phpbuilder.com/manual/lan...predefined.php

    Freddie the 2 ? in the query string are intentional (See top post) - I want everything after the initial, as the second ? should be treated as litteral and only refers to a variable when it is passed on via the second script. This works fine with say

    search.php?c=1&b=site.com?t=anothervariable

    when passed to the script variable b="site.com?t=anothervariable" and is not broken down (as intentioned).

    You possibly think why the hell am I passing variables like this - but believe me I do have reasons - and only very complicated alternatives!

    But the problem is with & charactors after the second ? which get treated as seperate vars - hence the problem.

    However, I think I have solved it and am just waiting to test:

    $REQUEST_URI;

    HTTP_SERVER_VARS[QUERY_STRING];


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •