emma57573 Posted February 15, 2009 Share Posted February 15, 2009 I cant get IPN working for my site. I know my scripts being called for as I get the following error in my error log [15-Feb-2009 16:31:34] PHP Parse error: syntax error, unexpected $end in /home/misimeuk/public_html/paypal.php on line 65 I cant find the sytax error however and its driving me up the wall. Are php includes allowed? im wondering if thats the issue here. The first include is connecting to the database and the second it calling the session so that I can get the $userid variable. Im sure its just an error in my scripting somewhere but I cant find where! This is the script in question include_once "connect.php"; include_once "session.php"; global $user; $userid=$user->data['user_id']; // read the post from PayPal system and add 'cmd' $req = 'cmd=_notify-validate'; foreach ($_POST as $key => $value) { $value = urlencode(stripslashes($value)); $req .= "&$key=$value"; } echo "test"; // 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.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']; // custom varible $invoice_id = $_POST['invoice_id']; //retrieve payment status $payment_status = $_POST['payment_status']; if (!$fp) { // HTTP ERROR } else { fputs ($fp, $header . $req); while (!feof($fp)) { $res = fgets ($fp, 1024); if (strcmp ($res, "VERIFIED") == 0) { // check the payment_status is Completed // check that txn_id has not been previously processed // check that receiver_email is your Primary PayPal email // check that payment_amount/payment_currency are correct // process payment if ($payment_status == "Completed") { mysql_query("update MYTABLE set pay='0' where buyer=$userid and item=$item_number" ); } else if (strcmp ($res, "INVALID") == 0) { // log for manual investigation } } fclose ($fp); } ?> Link to comment https://forums.phpfreaks.com/topic/145312-paypal-php-ipn-script-syntax-error/ Share on other sites More sharing options...
PFMaBiSmAd Posted February 15, 2009 Share Posted February 15, 2009 The error means that php reached the end of your file while it was still expecting php code. This is usually caused by missing or mis-matched braces {} around blocks of logic, but it can also be caused by a quoted string that is missing a closing quote. You need to proof read your code and make sure that all the syntax that is started is closed. If you were to use block level indentation in your source code so that all the lines of code within a block {} at the same level was indented the same amount, it would be easier to find where the problem is and it would also help prevent the problem because you would be able to see where {} belong. P.S. global $user; has absolutely no meaning unless it is inside of a function definition. Link to comment https://forums.phpfreaks.com/topic/145312-paypal-php-ipn-script-syntax-error/#findComment-762876 Share on other sites More sharing options...
emma57573 Posted February 15, 2009 Author Share Posted February 15, 2009 Thanks for your help It was as you say a missing bracket and I have put the $user call inside a function. The script is no longer logging an error its just not working... hum back to the drawing board then! Link to comment https://forums.phpfreaks.com/topic/145312-paypal-php-ipn-script-syntax-error/#findComment-763038 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.