Hey Guys,

It's me again....I thought everything would work but when I tried making a donation on my donation.php form I received the following error in my process_transaction.php file:

Here is the error:

Parse error: syntax error, unexpected $end in \\nawinfs02\home\users\web\b885\rh.mysite\orderform\process_transaction.php on line 224

My webhost is lame and does not give line numbers in their text editor. So here is the whole file, the error is toward the very bottom towards the last $message I believe:

Here is the process_transaction:

<?php
	include_once("gatewayapi/inc_gatewayapi.php");
	
	$transaction = new GatewayTransaction($_REQUEST, $_SERVER['REMOTE_ADDR']);
	
	if($transaction->ProcessTransaction($responseString, $errorCode))
	{
		$response = new GatewayResponse($responseString, $GatewaySettings['delim_char']);
		
		// Check MD5 Hash Value
		//
		 if($GatewaySettings['MD5Hash'] 
				&& !$response->VerifyMD5Hash($GatewaySettings['MD5Hash'],
														$transaction->username,
														$transaction->amount))
			{
				header("Location: " . $GatewaySettings['PaymentDeniedPage'] . "?gateway_error=" . rawurlencode($transaction->GetErrorString("INVALID_MD5HASH")));
				exit();
			}
		 	

		
		if($response->IsApproved())
		{
	        $to = 'donation@mysite.org';  
            	$subject = 'New Donation';
            	$header = 'From: no-reply@mysite.org';
                $message = '<html><body>';
                $message .= '<img src="http://mysite.org/images/emailbanner.jpg" alt="Email Banner" />';
                $message .= '<table rules="all" style="border-color: #666;" cellpadding="10">';
                $message .= "<head>";
                $message .= "<title>Donation Information</title>";
                $message .= "</head>";
                $message .= "<body>";
                $message .= "<tr style='background: #eee;'><strong><p>Donation Information</strong></p></tr>";
                $message .= "<table>";
                $message .= "<tr>";
                $message .= "<th><p>Donation Amount:</p></th>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<td>{$_GET['amount']}</td>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<th>Designation:</th>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<td>{$_GET['Desc']}</td>";
                $message .= "</tr>";
                $message .= "</table>";
                $message .= "<tr style='background: #eee;'><strong><p>Billing Information</strong></p></tr>";
                $message .= "<table>";
                $message .= "<tr>";
                $message .= "<th>First Name:</th>";
                $message .= "<th>Last Name:</th>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<td>{$_GET['first_name']}</td>";
                $message .= "<td>{$_GET['last_name']}</td>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<th>Spouse Name:</th>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<td>{$_GET['Spouse']}</td>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<th>Address:</th>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<td>{$_GET['address']}</td>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<th>City:</th>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<td>{$_GET['city']}</td>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<th>State:</th>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<td>{$_GET['state']}</td>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<th>Zip Code:</th>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<td>{$_GET['zip']}</td>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<th>Country:</th>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<td>{$_GET['country']}</td>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<th>Phone Number:</th>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<td>{$_GET['phone']}</td>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<th>Email Address:</th>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<td>{$_GET['email']}</td>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<th>Credit Card:</th>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<td>XXXX-XXXX-XXXX-".substr($_GET['cc_number'] , -4, 4)."</td>";
                $message .= "</tr>";
                $message .= "</table>";
                $message .= "<tr style='background: #eee;'><strong><p>Shipping Information</strong></p></tr>";
                $message .= "<table>";
                $message .= "<tr>";
                $message .= "<th>First Name:</th>";
                $message .= "<th>Last Name:</th>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<td>{$_GET['shipping_first_name']}</td>";
                $message .= "<td>{$_GET['shipping_last_name']}</td>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<th>Address:</th>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<td>{$_GET['shipping_address']}</td>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<th>City:</th>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<td>{$_GET['shipping_city']}</td>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<th>State:</th>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<td>{$_GET['shipping_state']}</td>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<th>Zip Code:</th>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<td>{$_GET['shipping_zip']}</td>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<th>Country:</th>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<td>{$_GET['shipping_country']}</td>";
                $message .= "</tr>";
                $message .= "</table>";
                $message .= "<tr style='background: #eee;'><strong><p>Gift of Love</strong></p></tr>";
                $message .= "<table>";
                $message .= "<tr>";
                $message .= "<th>This gift is:</th>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<td>{$_GET['GiftDesc1']}</td>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<th>Is this a pet?</th>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<td>{$_GET['IsThisaPet']}</td>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<th>If a pet what kind:</th>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<td>{$_GET['TypeofPet']}</td>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<th>Name:</th>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<td>{$_GET['GiftDesc2']}</td>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<th>Address:</th>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<td>{$_GET['GOLAddress']}</td>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<th>City:</th>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<td>{$_GET['GOLCity']}</td>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<th>State:</th>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<td>{$_GET['GOLState']}</td>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<th>Zip:</th>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<td>{$_GET['GOLZip']}</td>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<th>Country:</th>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<td>{$_GET['GOLCountry']}</td>";
                $message .= "</tr>";
                $message .= "</table>";
                $message .= "</body></html>";

            	if (mail($to, $subject, $message, $header)) {
            		header("Location: " . $GatewaySettings['PaymentApprovedPage']);
		}
		else
			header("Location: " . $GatewaySettings['PaymentDeniedPage'] . "?gateway_error=" . rawurlencode($response->GetField("ResponseReasonText")));
	}
	else
			header("Location: " . $GatewaySettings['PaymentDeniedPage'] . "?gateway_error=" . rawurlencode($transaction->GetErrorString($errorCode)));

?>

I have no idea what the problem is, the code looks right. A special thanks to the Dani Web members who have helped me in the past with cleaning up this form : )

Any Ideas?

should an else not have braces before and after?
} else {
code
}else{

Either that, or you could try a switch statement

The braces go there I believe. Thanks though, I might try a switch statement. I don't think it was the else statements that caused that error but it never hurts to try. Thanks for the input

Any other advice?

should an else not have braces before and after?
} else {
code
}else{

Either that, or you could try a switch statement

Member Avatar for diafol
unexpected $end

Usually points to an unclosed brace/bracket of some description. Although I've seen numerous permutaions of if/else statement formats. I always find safety in the example

if(...){
   if(...){
        ....
   }
}elseif(...){
   if(...){
        ....
   }elseif(...){
        ....
   }else{
        ....
   }
}else{
   .....
}

It's quite straightforward then to check open/closed braces (and brackets).

commented: Ardav Helped a Bunch! +1

Thanks Ardav,

Not sure where it is but I will continue to look. It doesn't show up in the Syntax Highlighter and all the code looks right. If anyone spots it before me, please help to point it out : )

unexpected $end

Usually points to an unclosed brace/bracket of some description.

Member Avatar for diafol

Sorry edited my code while you replied!

Haha, well I looked over the examples and it makes sense. For some reason when I try that on the bottom else statements it does not make a difference. It all worked until I added the IfApproved email message to me. It is an html email that is sent to me if return value is approved. What it did before is just send the customer to an approved/denied page. I haven't even touched the bottom else statements. All I added was the following code:

if($response->IsApproved())
		{
	        $to = 'donation@mysite.org';  
            	$subject = 'New Donation';
            	$header = 'From: no-reply@mysite.org';
                $message = '<html><body>';
                $message .= '<img src="http://mysite.org/images/emailbanner.jpg" alt="VAC Email Banner" />';
                $message .= '<table rules="all" style="border-color: #666;" cellpadding="10">';
                $message .= "<head>";
                $message .= "<title>Donation Information</title>";
                $message .= "</head>";
                $message .= "<body>";
                $message .= "<tr style='background: #eee;'><strong><p>Donation Information</strong></p></tr>";
                $message .= "<table>";
                $message .= "<tr>";
                $message .= "<th><p>Donation Amount:</p></th>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<td>{$_GET['amount']}</td>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<th>Designation:</th>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<td>{$_GET['Desc']}</td>";
                $message .= "</tr>";
                $message .= "</table>";
                $message .= "<tr style='background: #eee;'><strong><p>Billing Information</strong></p></tr>";
                $message .= "<table>";
                $message .= "<tr>";
                $message .= "<th>First Name:</th>";
                $message .= "<th>Last Name:</th>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<td>{$_GET['first_name']}</td>";
                $message .= "<td>{$_GET['last_name']}</td>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<th>Spouse Name:</th>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<td>{$_GET['Spouse']}</td>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<th>Address:</th>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<td>{$_GET['address']}</td>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<th>City:</th>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<td>{$_GET['city']}</td>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<th>State:</th>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<td>{$_GET['state']}</td>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<th>Zip Code:</th>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<td>{$_GET['zip']}</td>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<th>Country:</th>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<td>{$_GET['country']}</td>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<th>Phone Number:</th>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<td>{$_GET['phone']}</td>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<th>Email Address:</th>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<td>{$_GET['email']}</td>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<th>Credit Card:</th>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<td>XXXX-XXXX-XXXX-".substr($_GET['cc_number'] , -4, 4)."</td>";
                $message .= "</tr>";
                $message .= "</table>";
                $message .= "<tr style='background: #eee;'><strong><p>Shipping Information</strong></p></tr>";
                $message .= "<table>";
                $message .= "<tr>";
                $message .= "<th>First Name:</th>";
                $message .= "<th>Last Name:</th>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<td>{$_GET['shipping_first_name']}</td>";
                $message .= "<td>{$_GET['shipping_last_name']}</td>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<th>Address:</th>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<td>{$_GET['shipping_address']}</td>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<th>City:</th>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<td>{$_GET['shipping_city']}</td>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<th>State:</th>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<td>{$_GET['shipping_state']}</td>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<th>Zip Code:</th>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<td>{$_GET['shipping_zip']}</td>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<th>Country:</th>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<td>{$_GET['shipping_country']}</td>";
                $message .= "</tr>";
                $message .= "</table>";
                $message .= "<tr style='background: #eee;'><strong><p>Gift of Love</strong></p></tr>";
                $message .= "<table>";
                $message .= "<tr>";
                $message .= "<th>This gift is:</th>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<td>{$_GET['GiftDesc1']}</td>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<th>Is this a pet?</th>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<td>{$_GET['IsThisaPet']}</td>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<th>If a pet what kind:</th>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<td>{$_GET['TypeofPet']}</td>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<th>Name:</th>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<td>{$_GET['GiftDesc2']}</td>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<th>Address:</th>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<td>{$_GET['GOLAddress']}</td>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<th>City:</th>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<td>{$_GET['GOLCity']}</td>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<th>State:</th>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<td>{$_GET['GOLState']}</td>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<th>Zip:</th>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<td>{$_GET['GOLZip']}</td>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<th>Country:</th>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<td>{$_GET['GOLCountry']}</td>";
                $message .= "</tr>";
                $message .= "</table>";
                $message .= "</body></html>";

            	if (mail($to, $subject, $message, $header))
		{
			header("Location: " . $GatewaySettings['PaymentApprovedPage']);
		}

Sorry edited my code while you replied!

Ok I figured it out, thanks everyone! There was an extra { curly bracket so I took it out. Now it works like this

if (mail($to, $subject, $message, $header))
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.