282 users online (0 members and 282 guests)  


  Results 1 to 3 of 3

Related

  1. Hi Noobie Here, Hope to Hear from All of You    Forum: General Discussion
    Replies: 1
  2. a help needed    Forum: HTML Forum
    Replies: 1
  3. help needed    Forum: Myspace Forum
    Replies: 4
  4. A Lot of Help Needed    Forum: Javascript Forum
    Replies: 1
  5. Help needed with DBD and DBI    Forum: CGI Perl Forum
    Replies: 8
  1. #1
    aodat2's Avatar
    New User

    Status
    Offline
    Join Date
    Aug 2008
    Posts
    2

    PHP Help Needed - Noobie

    I was given a code which I am suppose to incorporate into my website.

    Can someone be kind enough to help me by telling me what I should do here to make the code work? I do understand that in the end of the Function, it will return a value or something like that which is in the variable $Result but can someone tell me what else I am suppose to do to get the Function working or how am I suppose to call the Function?

    Thanks a lot for the help in advance.
    Code:
    <?PHP
    function Requery(){
    $query = "http://www.yourdomain.com/?MerchantCode=" .
    $MerchantCode . "&RefNo=" . $RefNo . "&Amount=" . $Amount;
    $url = parse_url($query);
    $host = $url["host"];
    $path = $url["path"] . "?" . $url["query"];
    $timeout = 1;
    $fp = fsockopen ($host, 80, $errno, $errstr, $timeout);
    if ($fp) {
    fputs ($fp, "GET $path HTTP/1.0\nHost: " . $host . "\n\n");
    while (!feof($fp)) {
    $buf .= fgets($fp, 128);
    }
    $lines = split("\n", $buf);
    $Result = $lines[count($lines)-1];
    fclose($fp);
    } else {
    # enter error handing code here
    }
    return $Result;
    }
    ?>

  2. #2
    aodat2's Avatar
    New User

    Status
    Offline
    Join Date
    Aug 2008
    Posts
    2

    Re: PHP Help Needed - Noobie

    Ok, I think I got this part working already.

    The only problem I have now is what's left unknown. I have the variables $MerchantCode and $RefNo but I do not have the amount.

    Could you tell me how I could obtain a value from a MySQL table?

    Example:
    Payment_Table contains the fields Name, Address, Amount, RefNo and Transaction_ID.

    How could I get the variable from the MySQL table out so that I could use it?

    Thanks for the help in advance.

  3. #3
    jthayne's Avatar

    Status
    Offline
    Join Date
    Aug 2008
    Location
    Texas
    Posts
    508

    Re: PHP Help Needed - Noobie

    In order to do what you are asking, you will need to alter the function a little. The best way to alter it is as follows:

    Code:
    <?PHP
    function Requery($MerchantCode, $RefNo, $Amount){
    ...
    } // end of function
    
    // connect to database first
    $mer_code = "xxxxxxxxxxxx";
    $res = mysql_query("SELECT * FROM Payment_Table");
    foreach ($res as $key => $value) {
    // This will run the function on each entry in the database.
    // If you want to only run it on one, you will need to filter the mysql query with a WHERE statement.
    Requery($mer_code, $res['RefNo'], $res['Amount'])
    }
    ?>
    Alternately, you can get the information from the database within the function.

    Let me know if you need any additional assistance.



Tags for this Thread