Hi,
does anyone know how to clear the outputs in php,
i have some code for paypal that checks if payment has been made then i have a exec function which doesnt work after the paypal output
do you use flush or someting
thanks reece
php clearing output
Moderator: General Moderators
- aaronhall
- DevNet Resident
- Posts: 1040
- Joined: Tue Aug 13, 2002 5:10 pm
- Location: Back in Phoenix, missing the microbrews
- Contact:
Are you using output buffering? ob_flush() would do the trick.
I'm not clear on why exec() and Paypal's API would need to be used together.
I'm not clear on why exec() and Paypal's API would need to be used together.
its a database system i need paypal to check for payment then creates a database using exec
this is the php for paypal
i have tried ob_flush( but i dont think this is related to the paypal output
doesnt the fclose sort it
thanks
reece
this is the php for paypal
Code: Select all
// post back to PayPal system to validate
$header .= "POST /cgi-bin/webscr HTTP/1.0\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
$fp = fsockopen ('www.sandbox.paypal.com', 80, $errno, $errstr, 30);
fclose ($fp);i have tried ob_flush( but i dont think this is related to the paypal output
doesnt the fclose sort it
thanks
reece
You do not send the contents of $req, you're only setting the Content-Length header.
Take a look at http://devzone.zend.com/search/results?q=paypal
do you mean this
i dint post the whole code
thanks
i dint post the whole code
Code: Select all
$req = 'cmd=_notify-validate';
foreach ($_POST as $key => $value) {
$value = urlencode(stripslashes($value));
$req .= "&$key=$value";
//Remove this line after you have debugged
//print $req;
}
// post back to PayPal system to validate
$header .= "POST /cgi-bin/webscr HTTP/1.0\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
$fp = fsockopen ('www.sandbox.paypal.com', 80, $errno, $errstr, 30);
// assign posted variables to local variables
$item_name = $_POST['item_name'];
$item_number = $_POST['item_number'];
$payment_status = $_POST['payment_status'];
$payment_amount = $_POST['mc_gross'];
$payment_currency = $_POST['mc_currency'];
$txn_id = $_POST['txn_id'];
$receiver_email = $_POST['receiver_email'];
$payer_email = $_POST['payer_email'];
if (!$fp) {
// HTTP ERROR
} else {
fputs ($fp, $header . $req);
while (!feof($fp)) {
$res = fgets ($fp, 1024);
if (strcmp ($res, "VERIFIED") == 0) {
print "VERIFIED";
$verified="yes";
}
else if (strcmp ($res, "INVALID") == 0) {
// log for manual investigation
die ("NOT VERIFIED");
}
}
fclose ($fp);
}}