Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 08-13-2008, 01:34 PM   PM User | #1
aodat2
New to the CF scene

 
Join Date: Aug 2008
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
aodat2 is an unknown quantity at this point
Question Noobie Needs PHP Help

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;
}
?>
aodat2 is offline   Reply With Quote
Old 08-13-2008, 03:12 PM   PM User | #2
aodat2
New to the CF scene

 
Join Date: Aug 2008
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
aodat2 is an unknown quantity at this point
Oh ok, I think I got it 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.
aodat2 is offline   Reply With Quote
Old 08-13-2008, 03:25 PM   PM User | #3
ohgod
Regular Coder

 
ohgod's Avatar
 
Join Date: Jun 2008
Location: Ohio
Posts: 579
Thanks: 6
Thanked 69 Times in 69 Posts
ohgod is on a distinguished road
http://us3.php.net/manual/en/ref.mysql.php

more specifically, http://us3.php.net/manual/en/function.mysql-query.php

but you'll need other functions from the first link working in concert to do anything useful with the results.
ohgod is offline   Reply With Quote
Old 08-13-2008, 05:39 PM   PM User | #4
aodat2
New to the CF scene

 
Join Date: Aug 2008
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
aodat2 is an unknown quantity at this point
The funniest problem is that I got everything correct already. But when I try running the script and see if it works, it gives me "Invalid Parameter". Not too sure what's wrong but if you actually enter the URL into the browser, it will work perfectly fine.

Something is definitely wrong somewhere. Can someone actually help me by telling me what I did wrong or where is wrong?

Code:
$MerchantCode = "12345";
$RefNo = "22";
$Amount_Paid = "1.00";

function Requery(){
$query = "http://www.mobile88.com/epayment/enquiry.asp?MerchantCode=" .
$MerchantCode . "&RefNo=" . $RefNo . "&Amount=" . $Amount_Paid;
$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;
}

$verify = Requery();
echo $verify;
aodat2 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 04:34 AM.


Advertisement
Log in to turn off these ads.