Let me say I am a beginner ColdFusion programmer. I'm having trouble with a form & actionpage due to SQL statements. I've canvassed them a 1,00 times and can't see the error of my ways. Could someone help? Here is the current problem.
Form:
<!HwebPg3.cfm -- calls actionpage3.cfm>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<cfinsert datasource="Bizbul" TABLENAME="TRANSACTION">
<html>
<head>
<title>Hashemi Project Page 3</title>
<SCRIPT LANGUAGE="JavaScript">
document.write(Date());
</SCRIPT>
</head>
<body BGCOLOR="#BFA0D3" TEXT=Black>
<form action="actionpage3a.cfm" method="post">
<STRONG><center>DR. HASHEMI'S DATABASE: INSERT TRANSACTIONS</center></strong>
<br><br><br>
<table width=100% border=0 cellspacing=15 cellpadding=5>
<tr>1. The transaction number is: <INPUT TYPE="text" NAME="T_id" SIZE="8" MAXLENGTH="8"><br><br>
</tr>
<tr>2. The transaction type isreturn or purchase) <INPUT TYPE="text" NAME="trans_type" SIZE="8" MAXLENGTH="8"><br><br>
</tr>
<tr>3. The customer's ID# is: <INPUT TYPE="text" NAME="id" SIZE="8" MAXLENGTH="8"><br><br>
</tr>
<tr>4. The item # is: <INPUT TYPE="text" NAME="item_num" SIZE="8" MAXLENGTH="8"><br><br>
</tr>
<tr>5. The model number is: <INPUT TYPE="text" NAME="model_num" SIZE="10" MAXLENGTH="10"><br><br>
</tr>
<tr>6. The date is: <INPUT TYPE="text" NAME="date" SIZE=""15 MAXLENGTH="15"><br><br>
</tr>
<tr>7. The quantity is: <INPUT TYPE="text" NAME="qty" SIZE="8" MAXLENGTH="8"><br><br>
</tr>
<tr>8. The price is: <INPUT TYPE="text" NAME="price" SIZE="15" MAXLENGTH="15"><br><br>
</tr>
<tr>9. The total cost is: <INPUT TYPE="text" NAME="total_cost" SIZE="15" MAXLENGTH="15"><br>
</tr>
<tr>
<th><IMG LENGTH=100% SRC="lines_pp_022.gif">
</th>
</tr>
<tr>
<th align="center"><INPUT TYPE="submit" NAME="SubmitForm" VALUE="Submit"> <INPUT TYPE="reset" NAME="ResetForm" VALUE="Clear Form">
</th>
</tr>
</TABLE>
</form>
</body>
</html>
-----------------------------------------------------------
ACTION PAGE:
<html>
<head>
<title>Updated Database</title>
</header>
<body BGCOLOR="#ccccff">
<CFQUERY NAME="AddTrans" DATASOURCE="bizbul">
INSERT INTO TRANSACTION ('#Form.T_id#', '#Form.trans_type#', '#Form.id#',
'#Form.item_num#', '#Form.model_num#', '#Form.date#', '#Form.qty#', '#Form.price#', '#Form.total_cost#')
</CFQUERY>
<h1>Transaction Added</h1><br><br>
<b>You have added the transaction/s:</b><br>
<cfoutput query="AddTrans">
<table BORDER="5" CELLPADDING="5" CELLSPACING="5">
<tr>
<td>Transaction ID Num</td>
<td>Transaction type</td>
<td>ID Num</td>
<td>Item Num</td>
<td>Model Num</td>
<td>Date</td>
<td>Quantity</td>
<td>Price</td>
<td>Total Cost</td>
</tr>
<tr>
<td>#T_id#</td>
<td>#trans_type#</td>
<td>#id#</td>
<td>#item_num#</td>
<td>#model_num#</td>
<td>#date#</td>
<td>#qty#</td>
<td>#price#</td>
<td>#total_cost#</td>
</tr>
</table>
</cfoutput><br><br>
<CFQUERY NAME="ItemUpdate" DATASOURCE="bizbul">
<CFIF Form.trans_type IS "return">
UPDATE Item
SET UnitsInStock = UnitsInStock + #Form.qty#
WHERE item_no = '#Form.item_num#'
<CFELSEIF Form.trans_type IS "purchase">
UPDATE ITEM
SET UnitsInStock = UnitsInStock - #Form.qty#
WHERE item_no = '#Form.item_num#'
</CFIF>
</CFQUERY>
<CFQUERY NAME="CustUpdate" DATASOURCE="bizbul">
<CFIF Form.trans_type IS "return">
UPDATE CUSTOMER
SET balance = balance + #Form.total_cost#
WHERE id='#Form.id#'
<CFELSEIF Form.trans_type IS "purchase">
UPDATE CUSTOMER
SET balance = balance - #Form.total_cost#
WHERE id = '#Form.id#'
</CFIF>
</CFQUERY>
<CFQUERY NAME="PrintOut" DATASOURCE="bizbul">
SELECT *
FROM Item
WHERE item_no = '#Form.item_num#'
</CFQUERY>
<CFQUERY NAME="CustomerOut" DATASOURCE="bizbul">
SELECT id, name, city, state, zip, balance
FROM Customer
WHERE id = '#Form.id#'
</cfquery>
<b>You have also updated the inventory:</b>
<cfoutput query="PrintOut">
<table BORDER="5" CELLPADDING="5" CELLSPACING="5">
<tr>
<td>Item Num</td>
<td>Model Num</td>
<td>Units In Stock</td>
<td>Unit Price</td>
</tr>
<tr>
<td>#item_no#</td>
<td>#model_no#</td>
<td>#UnitsInStock#</td>
<td>#UnitPrice#</td>
</tr>
</table>
</cfoutput><br><br>
<b>You have also updated the customer's balance:</b>
<cfoutput query="CustomerOut">
<table BORDER="5" CELLPADDING="5" CELLSPACING="5">
<tr>
<td>Id</td>
<td>Name</td>
<td>City</td>
<td>State</td>
<td>Zip</td>
<td>Balance</td>
</tr>
<tr>
<td>#id#</td>
<td>#name#</td>
<td>#city#</td>
<td>#state#</td>
<td>#zip#</td>
<td>#balance#</td>
</tr>
</table>
</cfoutput><br><br>
</body>
</html>
------------------------------------------------------------
I really really appreciate your help and time
Jennifer
Form:
<!HwebPg3.cfm -- calls actionpage3.cfm>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<cfinsert datasource="Bizbul" TABLENAME="TRANSACTION">
<html>
<head>
<title>Hashemi Project Page 3</title>
<SCRIPT LANGUAGE="JavaScript">
document.write(Date());
</SCRIPT>
</head>
<body BGCOLOR="#BFA0D3" TEXT=Black>
<form action="actionpage3a.cfm" method="post">
<STRONG><center>DR. HASHEMI'S DATABASE: INSERT TRANSACTIONS</center></strong>
<br><br><br>
<table width=100% border=0 cellspacing=15 cellpadding=5>
<tr>1. The transaction number is: <INPUT TYPE="text" NAME="T_id" SIZE="8" MAXLENGTH="8"><br><br>
</tr>
<tr>2. The transaction type isreturn or purchase) <INPUT TYPE="text" NAME="trans_type" SIZE="8" MAXLENGTH="8"><br><br>
</tr>
<tr>3. The customer's ID# is: <INPUT TYPE="text" NAME="id" SIZE="8" MAXLENGTH="8"><br><br>
</tr>
<tr>4. The item # is: <INPUT TYPE="text" NAME="item_num" SIZE="8" MAXLENGTH="8"><br><br>
</tr>
<tr>5. The model number is: <INPUT TYPE="text" NAME="model_num" SIZE="10" MAXLENGTH="10"><br><br>
</tr>
<tr>6. The date is: <INPUT TYPE="text" NAME="date" SIZE=""15 MAXLENGTH="15"><br><br>
</tr>
<tr>7. The quantity is: <INPUT TYPE="text" NAME="qty" SIZE="8" MAXLENGTH="8"><br><br>
</tr>
<tr>8. The price is: <INPUT TYPE="text" NAME="price" SIZE="15" MAXLENGTH="15"><br><br>
</tr>
<tr>9. The total cost is: <INPUT TYPE="text" NAME="total_cost" SIZE="15" MAXLENGTH="15"><br>
</tr>
<tr>
<th><IMG LENGTH=100% SRC="lines_pp_022.gif">
</th>
</tr>
<tr>
<th align="center"><INPUT TYPE="submit" NAME="SubmitForm" VALUE="Submit"> <INPUT TYPE="reset" NAME="ResetForm" VALUE="Clear Form">
</th>
</tr>
</TABLE>
</form>
</body>
</html>
-----------------------------------------------------------
ACTION PAGE:
<html>
<head>
<title>Updated Database</title>
</header>
<body BGCOLOR="#ccccff">
<CFQUERY NAME="AddTrans" DATASOURCE="bizbul">
INSERT INTO TRANSACTION ('#Form.T_id#', '#Form.trans_type#', '#Form.id#',
'#Form.item_num#', '#Form.model_num#', '#Form.date#', '#Form.qty#', '#Form.price#', '#Form.total_cost#')
</CFQUERY>
<h1>Transaction Added</h1><br><br>
<b>You have added the transaction/s:</b><br>
<cfoutput query="AddTrans">
<table BORDER="5" CELLPADDING="5" CELLSPACING="5">
<tr>
<td>Transaction ID Num</td>
<td>Transaction type</td>
<td>ID Num</td>
<td>Item Num</td>
<td>Model Num</td>
<td>Date</td>
<td>Quantity</td>
<td>Price</td>
<td>Total Cost</td>
</tr>
<tr>
<td>#T_id#</td>
<td>#trans_type#</td>
<td>#id#</td>
<td>#item_num#</td>
<td>#model_num#</td>
<td>#date#</td>
<td>#qty#</td>
<td>#price#</td>
<td>#total_cost#</td>
</tr>
</table>
</cfoutput><br><br>
<CFQUERY NAME="ItemUpdate" DATASOURCE="bizbul">
<CFIF Form.trans_type IS "return">
UPDATE Item
SET UnitsInStock = UnitsInStock + #Form.qty#
WHERE item_no = '#Form.item_num#'
<CFELSEIF Form.trans_type IS "purchase">
UPDATE ITEM
SET UnitsInStock = UnitsInStock - #Form.qty#
WHERE item_no = '#Form.item_num#'
</CFIF>
</CFQUERY>
<CFQUERY NAME="CustUpdate" DATASOURCE="bizbul">
<CFIF Form.trans_type IS "return">
UPDATE CUSTOMER
SET balance = balance + #Form.total_cost#
WHERE id='#Form.id#'
<CFELSEIF Form.trans_type IS "purchase">
UPDATE CUSTOMER
SET balance = balance - #Form.total_cost#
WHERE id = '#Form.id#'
</CFIF>
</CFQUERY>
<CFQUERY NAME="PrintOut" DATASOURCE="bizbul">
SELECT *
FROM Item
WHERE item_no = '#Form.item_num#'
</CFQUERY>
<CFQUERY NAME="CustomerOut" DATASOURCE="bizbul">
SELECT id, name, city, state, zip, balance
FROM Customer
WHERE id = '#Form.id#'
</cfquery>
<b>You have also updated the inventory:</b>
<cfoutput query="PrintOut">
<table BORDER="5" CELLPADDING="5" CELLSPACING="5">
<tr>
<td>Item Num</td>
<td>Model Num</td>
<td>Units In Stock</td>
<td>Unit Price</td>
</tr>
<tr>
<td>#item_no#</td>
<td>#model_no#</td>
<td>#UnitsInStock#</td>
<td>#UnitPrice#</td>
</tr>
</table>
</cfoutput><br><br>
<b>You have also updated the customer's balance:</b>
<cfoutput query="CustomerOut">
<table BORDER="5" CELLPADDING="5" CELLSPACING="5">
<tr>
<td>Id</td>
<td>Name</td>
<td>City</td>
<td>State</td>
<td>Zip</td>
<td>Balance</td>
</tr>
<tr>
<td>#id#</td>
<td>#name#</td>
<td>#city#</td>
<td>#state#</td>
<td>#zip#</td>
<td>#balance#</td>
</tr>
</table>
</cfoutput><br><br>
</body>
</html>
------------------------------------------------------------
I really really appreciate your help and time
Jennifer