#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Location
    Singapore
    Posts
    21
    Rep Power
    0
    As in PERL, if you got a CGI
    you call CGL?var=value

    you can with cgi-lib.pl

    $var="$in{'var'}";
    so that $var will contain value.

    What is the PHP equilavent?

    Thanks in advance.
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Posts
    27
    Rep Power
    0
    PHP simplifies it more so than PERL...

    take your location string: blah?var=value

    to do something such as print 'value'... in the file that the form links to, just write:
    <?
    print $var;
    ?>


    //ryan
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Location
    Singapore
    Posts
    21
    Rep Power
    0
    Are you sure?
    I tried but it cannot work.

    But
    <?
    $var=HTTP_GET_VARS["text"];
    echo "Value of var is $var";
    ?>

    will work.
  6. #4
  7. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2000
    Posts
    5
    Rep Power
    0
    I have the same problem, but neither approach is working for me.

    When I use HTTP_GET_VARS["text"], I get an error.

  8. #5
  9. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2000
    Posts
    5
    Rep Power
    0
    I was able to get HTTP_GET_VARS to work. I was missing the $ that preceeds it.

    Rookie error....

    Still can't reference the passed variables directly though.
    I checked, and TRACK_VARS = ON in my configuration. Any other ideas?

    This is what works:
    ---------------

    <?
    $var=$HTTP_GET_VARS["name"];
    ?>

    name = <? echo $var; ?>


    ----------------

    this doesn't:


    name = <? echo $name; ?>.


  10. #6
  11. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Posts
    27
    Rep Power
    0
    To magconpres::

    "name = <? echo $name; ?>."

    ...this will not work because the full statement needs to be encapsulated by PHP code markers, ie:

    <? $name = $name ?>

    ...but that code is redundant. To stress the point made by my first post, the "PHP equivalent" is exactly as I posted. Don't include that code into a CGI script, instead, put it into an HTML page. In my earlier post, I meant that PHP simplifies coding because with it, there is little to no need for CGI scripts. Sorry that my point didn't come across the first time. Hope this drives it home.

    Summing it up:

    if your 1st page links to your second like this: <a href="2.php?var=ryan">

    then the 2nd page (2.php) can use the variable $var freely, with the value "ryan" already initialized to it... no need for CGI

    //ryan
  12. #7
  13. .Net Developer
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2000
    Location
    London
    Posts
    987
    Rep Power
    15

    <<
    I have the same problem, but neither approach is working for me.
    When I use HTTP_GET_VARS["text"], I get an error.
    >>

    see the following discussion:
    http://www.phpbuilder.com/forum/read...&thread=100138



    ------------------
    SR -
    webshiju.com
    www.jobxyz.com-IT Career Portal
    ezipindia.com--WebStudio


    "The fear of the LORD is the beginning of knowledge..."

Similar Threads

  1. Passing POST variables
    By rlorenzo in forum PHP Development
    Replies: 11
    Last Post: June 6th, 2004, 03:00 PM
  2. help with assigning variables, variable passing/ retrieval
    By pinkipodmini in forum PHP Development
    Replies: 0
    Last Post: February 13th, 2004, 10:40 PM
  3. Replies: 2
    Last Post: February 11th, 2004, 12:03 AM
  4. read split variables from ASP
    By Taps in forum MS SQL Development
    Replies: 0
    Last Post: February 7th, 2004, 04:40 PM
  5. Replies: 4
    Last Post: January 11th, 2004, 12:34 PM

IMN logo majestic logo threadwatch logo seochat tools logo