pcw Posted March 2, 2009 Share Posted March 2, 2009 Hi, I am trying to write a payment script for my registration script that I have written. At the moment I am just trying to get the payment script to work itself. I have written a form that actions the script below, and get an error: Parse error: syntax error, unexpected T_ELSE in /home/moveitho/public_html/sitebuilder/payment.php on line 73 How can I fix this, and have I done anything else wrong? Any help is much appreciated. <?php # This opens the IPN log file and logs the time of payment $filename = "data/ipn.log"; $log = fopen( $filename, "a"); fwrite($log, "\n\nipn - " . gmstrftime ("%b %d %Y %H:%M:%S", time()) . "\n"); # This connects to the defined database include_once("data/required.php"); $db1 = mysql_connect("localhost", $dbuser, $dbpass); mysql_select_db($db, $db1); # This creates a reply to validate the IPN $postvars = array(); while (list ($key, $value) = each ($HTTP_POST_VARS)) { $postvars[] = $key; } $req = 'cmd=_notify-validate'; for ($var = 0; $var < count ($postvars); $var++) { $postvar_key = $postvars[$var]; $postvar_value = $$postvars[$var]; $req .= "&" . $postvar_key . "=" . urlencode($postvar_value); } # Create the HTTP header for the reply message $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); # Write the payment details to the log file fwrite($log, "Values: ". $sub_no." ". $mail_from." ". $subscription_name." ". $payment_status." ". $pending_reason." ". $payment_date." ". $price." ". $currency." ". $first_name." ". $last_name." ". $house_no." ". $address." ". $town." ". $county." ". $postcode." ". $country." ". $email." ". $subscription_status." ". $verify_sign." ". $referal_if. "\n"); # Check the HTTP connection to PayPal is successful if (!$fp) { print "$errstr ($errno)"; fwrite($log, "HTTP connection was unsuccessful!"); $res = "FAILED"; } # Posts variables to PayPal's server. If payment was successful, a verified response is returned else { fputs ($fp, $header . $req); while (!feof($fp)) { $res = fgets ($fp, 1024); if (strcmp ($res, "VERIFIED") == 0) { # If payment was successful if (strcmp ($payment_status, "Completed") == 0) { mysql_query("UPDATE Users SET verified = 'yes' WHERE username='$username'"); send_reg(); # Payment has not been completed } else { print "Payment not complete"; # Unverified payment } else { print "Suspicious payment"; } } } } # Insert details into databse $query = "INSERT into payment ( sub_no, mail_from, subscription_name, payment_status, pending_reason, payment_date, price, currency, first_name, last_name, house_no, address, town, county, postcode, country, email, subscription_status, verify_sign, referal_if ) VALUES ( '$_POST[sub_no]', '$_POST[mail_from]', '$_POST[subscription_name]', '$_POST[payment_status]', '$_POST[pending_reason]', '$_POST[payment_date]', '$_POST[price]', '$_POST[currency]', '$_POST[first_name], '$_POST[last_name]', '$_POST[house_no]', '$_POST[address]', '$_POST[town]', '$_POST[county]', '$_POST[postcode]', '$_POST[country]', '$_POST[email]', '$_POST[subscription_status]', '$_POST[verify_sign]', '$_POST[referal_if]' ) "; $result = mysql_query($query, $db); # Close files and database fclose ($fp); fclose ($log); mysql_close($db); ?> Quote Link to comment https://forums.phpfreaks.com/topic/147641-help-with-php-and-paypal-script/ Share on other sites More sharing options...
Maq Posted March 2, 2009 Share Posted March 2, 2009 You have 2 else statements; lines 67 & 73. You can only have 1. Quote Link to comment https://forums.phpfreaks.com/topic/147641-help-with-php-and-paypal-script/#findComment-775056 Share on other sites More sharing options...
pcw Posted March 2, 2009 Author Share Posted March 2, 2009 So what can I do to fix this? Quote Link to comment https://forums.phpfreaks.com/topic/147641-help-with-php-and-paypal-script/#findComment-775059 Share on other sites More sharing options...
Maq Posted March 2, 2009 Share Posted March 2, 2009 Take one out, doesn't matter which one... there's no point to have 2 anyway, they do the same thing. Quote Link to comment https://forums.phpfreaks.com/topic/147641-help-with-php-and-paypal-script/#findComment-775062 Share on other sites More sharing options...
DarkSuperHero Posted March 2, 2009 Share Posted March 2, 2009 you can do "else if()" but you would need to specify a condition.... Quote Link to comment https://forums.phpfreaks.com/topic/147641-help-with-php-and-paypal-script/#findComment-775081 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.