Need Help on passing var between PHP <----> CGI

Discussion in 'PHP' started by lovelyThumbsUp, Dec 5, 2008.

  1. #1
    Hey guys, I really need help on this passing value to CGI and get value back to PHP stuff work. Big Thanks

    Ok Here is my current code:
    
    <?php
    
       ob_start();
           passthru ("/usr/local/etc/httpd/htdocs/XXXX/testing.cgi");
           $results = ob_get_contents();
           ob_end_clean();
           echo $results;   
    
    ?>
    
    Code (markup):
    and Here is my CGI Code:

    
    #!/usr/bin/perl -wT
    
    sub test {
    
      my @n;
      $n[0] = 10;
      $n[1] = 17;
      $n[2] = 23;
      return @n;
      }
    
    ($first,$second,$third) = test();
    
    
    print "$first-$second-$third";
    
    Code (markup):

    If I run the code above I got this: 10-17-23

    !!!! BIG HOWEVER !!!!!

    I would like to pass a value $myNumber to $n[0];

    simple say the result I hope is:

    if I set $myNumber = 10000

    then I got this: 10000-17-23
     
    lovelyThumbsUp, Dec 5, 2008 IP
  2. lovelyThumbsUp

    lovelyThumbsUp Peon

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    The reason passing and retrieving value from CGI is, I need pass a value into a CGI function (large and complex function, no time to convert to php) and get the return of that CGI function and use it in the PHP script.

    And this may make it easier to under stand:
    ------------------------------------------
    
    #!/usr/bin/perl -wT
    
    sub test {
    
    my @n;
    $n[0] = $mySuperNumber(Somehow pass this value from php and use here);
    $n[1] = 17;
    
    $c = $n[0] + $n[1];
    
    return $c;
    
    }
    
    ($NewResult) = test();
    
    print "$NewResult";
    
    Code (markup):
    ----------------------------------------------

    Then I can use the php code above to get the value of this $NewResult

    Am I make myself clear?
     
    lovelyThumbsUp, Dec 5, 2008 IP
  3. lovelyThumbsUp

    lovelyThumbsUp Peon

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    problem solved!!!!!!!!!! so happy
     
    lovelyThumbsUp, Dec 8, 2008 IP
  4. atlantaazfinest

    atlantaazfinest Peon

    Messages:
    389
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #4
    post up how you fixed it may help a few people
     
    atlantaazfinest, Dec 8, 2008 IP