Link to home
Start Free TrialLog in
Avatar of Eric Bourland
Eric BourlandFlag for United States of America

asked on

syntax error in expressions structure

ColdFusion 9

Hi. I am working with some ColdFusion sample code supplied by authorize.net, and I am getting what looks like a syntax error. Here is the error:

Invalid CFML construct found on line 55 at column 41.
ColdFusion was looking at the following text:
,
The CFML compiler was processing:
    An expression beginning with (, on line 55, column 22.This message is usually caused by a problem in the expressions structure.
    A cfset tag beginning on line 55, column 2.
 
The error occurred in C:/websites/www.nnvawi.org/RegisterConference.cfm: line 55
53 : <!--- Because coldfusion's ListToArray object ignores empty fields, we must
54 : put a null in all empty fields to make sure that they are not skipped --->
55 : <cfset post_response=(cfhttp.filecontent, "||", "|null|", "all")>
56 : <!--- the same command is run twice, because the first time it only adjusts
57 : every other empty field --->

Open in new window


Here is the code ... I will include what seems relevant to the error, but please let me know if you need the entire form:

<!-----
Name:        RegisterConference.cfm
Author:      EB
Description: 1) process information for conference registrants; 2) populate authorize.net payment page with data entered in the registration form
Created:     July 2014
Revised: August 2014
ColdFusion Version 9
MS SQL Server 2012
----->


<!--- authorize.net stuff--->

<cfset paymentConfirmed="">

<cfhttp method="Post" url="https://secure.authorize.net/gateway/transact.dll">

	<!--- the API Login ID and Transaction Key must be done with valid values --->
	<cfhttpparam type="Formfield" name="x_login" value="xxxxxxxx">
	<cfhttpparam type="Formfield" name="x_tran_key" value="yyyyyyyValue">
	
	<cfhttpparam type="Formfield" name="x_delim_data" value="TRUE">
	<cfhttpparam type="Formfield" name="x_delim_char" value="|">
	<cfhttpparam type="Formfield" name="x_relay_response" value="FALSE">
	<cfhttpparam type="Formfield" name="x_duplicate_window" value="30">
	
	<cfhttpparam type="Formfield" name="x_type" value="AUTH_CAPTURE">
	<cfhttpparam type="Formfield" name="x_method" value="CC">
	<cfhttpparam type="Formfield" name="x_card_num" value=#cardNumber#>
	<cfhttpparam type="Formfield" name="x_exp_date" value=#cardDate#>
	<cfhttpparam type="Formfield" name="x_card_code" value=#cardCCV#>

	<cfhttpparam type="Formfield" name="x_amount" value=#totalBilled#>
	<cfhttpparam type="Formfield" name="x_description" value=#salesDescription#>
	
	<cfhttpparam type="Formfield" name="x_cust_id" value=#x_cust_id#>
	<cfhttpparam type="Formfield" name="x_invoice_num" value=#invoiceNumber#>
	<cfhttpparam type="Formfield" name="x_company" value=#x_company#>
	<cfhttpparam type="Formfield" name="x_first_name" value=#x_first_name#>
	<cfhttpparam type="Formfield" name="x_last_name" value=#x_last_name#>
	<cfhttpparam type="Formfield" name="x_address" value=#cardAddress#>
	<cfhttpparam type="Formfield" name="x_city" value=#cardCity#>
	<cfhttpparam type="Formfield" name="x_state" value=#cardState#>
	<cfhttpparam type="Formfield" name="x_zip" value=#cardZip#>
	<cfhttpparam type="Formfield" name="x_country" value=#cardCountry#>
	<cfhttpparam type="Formfield" name="x_email" value=#emailAddress#>
	<cfhttpparam type="Formfield" name="x_phone" value=#phone#>
	
	<cfhttpparam type="Formfield" name="x_line_item" value=#qbLineItem#>
		
</cfhttp>

<!--- Because coldfusion's ListToArray object ignores empty fields, we must
put a null in all empty fields to make sure that they are not skipped --->
<cfset post_response=(cfhttp.filecontent, "||", "|null|", "all")>
<!--- the same command is run twice, because the first time it only adjusts
every other empty field --->
<cfset post_response=(post_response, "||", "|null|", "all")>

<!--- now the ListToArray method can be used without skipping fields --->
<cfset response_array=ListToArray(post_response, "|")>

<cfparam name=response_array[1] default="">
<cfparam name=response_array[3] default="">

<cfset errorNetCardNumber="">
<cfset errorNetCardCCV="">
<cfset errorNetExpiration="">
<cfset errorNetCardAddress="">

<cfif response_array[1] is "1">
	<cfset errorpayment="0">
	<cfset paymentConfirmed="paymentConfirmed">
	<cfset errorPaymentMessage="">
	<cfelse>
	<cfset errorpayment="1">
	<cfset paymentConfirmed="declined">
	<cfset errorPaymentMessage="<h3><b>Your Credit Card has been 
declined. Please check your information and correct any 
errors.</h3>">
	<!--create card error messages-->
	
	<cfif response_array[3] is "6" or response_array[3] is "37">
		<cfset errorNetCardNumber="<h3>Your credit card number is 
invalid.</h3>">
		</cfif>
		
	<cfif response_array[3] is "7" or response_array[3] is "8">
		<cfset errorNetCardNumber="<h3>Please check your card number, 
expiration, CCV, and address.</h3>">
		</cfif>
		
	<cfif response_array[3] is "11" >
		<cfset errorPaymentMessage="<h3>This submission of your Credit 
Card has been declined because it is a duplicate entry.<br>Please wait a few 
moments before resubmitting it.</h3>">
		</cfif>
		
	<cfif  response_array[3] is "45" or response_array[3] is "65" >
		<cfset errorNetCardNumber="<h3>Please check your card number, 
expiration, CCV, and address, one at least does not match.</h3>">
		<cfset errorNetCardNumber="<h3>Please check your card number, 
expiration, CCV, and address, they don't match what is on file.</h3>">
		</cfif>
		
	<cfif response_array[3] is "27">
		<cfset errorNetCardNumber="<h3>There is an error in your card 
information.
		<br>Please check your card number, expiration, CCV, or 
address.</h3>">
		</cfif> 	
		 
</cfif>

<!--- /authorize.net stuff --->

Open in new window


I am not sure what I am doing to cause a problem in the expressions structure. What am I missing?

Thanks as always. =)

Eric
Avatar of _agx_
_agx_
Flag of United States of America image

From the comments, it looks like they meant to do some sort of replace but forgot to include the function name before the "(" in these two lines:

     <cfset post_response=(cfhttp.filecontent, "||", "|null|", "all")>
     <cfset post_response=(post_response, "||", "|null|", "all")>

Try adding the "replace" function:

     <cfset post_response= replace(cfhttp.filecontent, "||", "|null|", "all")>
     <cfset post_response= replace(post_response, "||", "|null|", "all")>

That said... the example seems like it was written for an old version of CF.  The comment about list functions and empty elements is no longer true.  Might want to rewrite some of it to take advantage of newer functionality.
ASKER CERTIFIED SOLUTION
Avatar of _agx_
_agx_
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Eric Bourland

ASKER

_agx_

Good morning. It's working; your solution makes sense. I am working with sample code from the authorize.net web site; this deprecated code was written years ago.

My current task is to have people fill out a simple conference registration form, selecting an attendance option and an appropriate fee -- submit the form -- and then display the filled-out authorize.net payment form, where the user can then fill in credit card info. (I do not want to deal with credit cards and PCI compliance; I will let authorize.net handle this.) This has been an ongoing challenge -- but I am learning a lot.

This solution works great. =)

Eric
Thanks as always. _agx_. Hope you're great.

Eric