Page 1 of 1

php clearing output

Posted: Tue Jan 23, 2007 5:03 am
by reecec
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

Posted: Tue Jan 23, 2007 6:14 am
by aaronhall
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.

Posted: Tue Jan 23, 2007 10:08 am
by reecec
its a database system i need paypal to check for payment then creates a database using exec


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

Posted: Tue Jan 23, 2007 10:47 am
by volka
:?: database creation via exec? Since it's not included in your code snippet I guess that's not the issue, so ...anyway.

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

Posted: Tue Jan 23, 2007 11:28 am
by reecec
do you mean this


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);
}}
thanks

Posted: Sun Jan 28, 2007 5:45 am
by reecec
it was two problems:

changed chmod and then still i needed to split it up into two files so both have now sorted it


thanks anyway