|
Rank: Starting Member
Groups: Registered
Joined: 12/22/2005 Posts: 2 Location: ,
|
Try as I may, I cannot get my script to write to a database. I am able to get my ipn script to write to a txt file. However, I am more concerned about writing my data to a database.The script below works fine writing to a text file. But how do I write to a database?
<cfset paypal_url="http://www.sandbox.paypal.com/cgi-bin/webscr">
<!--- Loop through ipn response and post back variables --->
<cfhttp url="#paypal_url#" method="post">
<cfloop collection="#Form#" item="i">
<cfhttpparam type="formfield" name="#LCase(i)#" value="#Form[i]#">
</cfloop>
<cfhttpparam type="formfield" name="cmd" value="_notify-validate">
</cfhttp>
<!--- Parse IPN Response --->
<cfif ReFindNoCase("VERIFIED","#CFHTTP.FileContent#")>
<cfinclude template="ipn_success.cfm">
<cfelse>
<cfinclude template="ipn_error.cfm">
</cfif>
<cfset postData="">
<cfloop index="i" list="#Form.FieldNames#">
<cfset postData=#postData# & #Form[i]# & ",">
</cfloop>
<!--- Write Log --->
<cflock name="paypal_lock" type="exclusive" timeout="30">
<cffile action="append" file="#GetDirectoryFromPath(GetTemplatePath())#logs/ipn_success.txt" mode="777" output="#postData#" addnewline="yes">
</cflock>
I tried removing the above write log and enter the following code:
<cfquery name="qInsertCustomer" datasource="#application.main#">
INSERT INTO Customers(
first_name,
last_name,
email,
address,
city,
state,
zip,
payer_id,
)
VALUES(
'#FORM.first_name#',
'#FORM.last_name#',
'#FORM.payer_email#',
'#FORM.address_street#',
'#FORM.address_city#',
'#FORM.address_state#',
'#FORM.address_zip#',
'#FORM.payer_id#',
)
</cfquery>
Any suggestiosn or direction would be greatly appreciated.
One desperate dude,
Rick
|
|
Rank: Starting Member
Groups: Registered
Joined: 12/19/2005 Posts: 15 Location: ,
|
No commas after the last items in the query. (I do that all the time too!)
INSERT INTO Customers( ... payer_id, ) VALUES( ... '#FORM.payer_id#', )
|