[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 301
  • Last Modified:

Update/Edit data on developed webpage using coldfusion

I am using the code below on a web page I developed to update/edit some data using coldfusion. Currently when I click the "edit button" for some of the records displayed I do not get an error but the data update does not happen successfully. For some other records I try to update on the webpage I get the following error message when clicking the edit button "Invalid data 18,18 for CFSQLTYPE CF_SQL_INTEGER."  What am I doing wrong?
<!-- If URL.From is defined and equals DoEdit, then update the table -->

<CFIF IsDefined("URL.From")>
<CFIF #URL.From# IS "DoEdit">

<CFUPDATE DATASOURCE="SSPSRs" TABLENAME="Issues">

</CFIF>
</CFIF>


<!-- The below code selects all data from the table -->

<CFQUERY NAME="all" DATASOURCE="SSPSRs">
select * from Issues where user_name = <cfoutput>'#url.user_name#'</cfoutput>;
</CFQUERY>



<body>
<a href="trackertabs.cfm?user_name=<cfoutput>#url.user_name#</cfoutput>&tab=2">
<img src="http://127.0.0.1:8500/TicketTracking/pics/imagesCA6WFWX0.jpg" width=50 height=50 alt="go back to service tab" border="0" /></a> 
</body>
<br>


<body> 
<center>
<font size=6>
My Service Requests (All)
</font>
</center>
<br>
</body>


<body>

<!-- If DoUpdate has been run a short note is given -->

<CFIF IsDefined("DoUpdate.RecordCount")>
<p><b>Thanks for your update!</b>
</CFIF>



<table border='0' width='100%' align='center' summary='script output'>

<tr bgcolor="#d3d3d3">
<th bgcolor="#d3d3d3"><font size=2><b>Service<br> Request #</b></font></th>
<th bgcolor="#d3d3d3"><font size=2></strong>Request</strong></font></th>
<th bgcolor="#d3d3d3"><font size=2></strong>Network</strong></font></th>
<th bgcolor="#d3d3d3"><font size=2></strong>Assigned To</strong></font></th>
<th bgcolor="#d3d3d3"><font size=2></strong>Customer</strong></font></th>
<th bgcolor="#d3d3d3"><font size=2></strong>Opened Date</strong></font></th>
<th bgcolor="#d3d3d3"><font size=2></strong>Closed Date</strong></font></th>
<th bgcolor="#d3d3d3"><font size=2></strong>Status</strong></font></th>
<th bgcolor="#d3d3d3"><font size=2></strong>Priority</strong></font></th>
<th bgcolor="#d3d3d3"><font size=2></strong>Description</strong></font></th>
<th bgcolor="#d3d3d3"><font size=2></strong>Date Completed</strong></font></th>
<th bgcolor="#d3d3d3"><font size=2></strong>Comments</strong></font></th>
<th></th>
</tr>

<!-- Here we check for the URL.From attribute -->

<CFIF IsDefined("URL.From")>

<!-- If URL.From just equals DoEdit, we simply just output the data, just as if it was undefined  -->

<CFIF #URL.From# IS "DoEdit">



<cfoutput query="all">
<tr>
<td><font size=2>#Ticket_num#</font></td>
<td><font size=2>#Title#</font></td>
<td><font size=2>#Network#</font></td>
<td><font size=2>#Assigned_To#</font></td>
<td><font size=2>#Customer#</font></td>
<td><font size=2>#DateFormat(Opened_Date,'mm/dd/yyyy')#</font></td>
<td><font size=2>#DateFormat(Closed_Date,'mm/dd/yyyy')#</font></td>
<td><font size=2>#Status#</font></td>
<td><font size=2>#Priority#</font></td>
<td><font size=2>#Description#</font></td>
<td><font size=2>#Date_Completed#</font></td>
<td><font size=2>#Comments#</font></td>

<!-- This is where the Edit button and form is created -->

<td>
<form action="mysrs.cfm?user_name=#url.user_name#&From=Edit&ID=#Ticket_num#" method="post">
<input type="submit" value="Edit">
</form>
</td>

</tr>
</CFOUTPUT>

<CFELSE>

<CFLOOP QUERY="all">

<CFIF #URL.ID# IS #all.Ticket_Num#>

<CFOUTPUT>

<form action="mysrs.cfm?user_name=#url.user_name#&From=DoEdit&ID=#Ticket_num#" method="post">

<tr>
<td><font size=2><input type="text" name="Ticket_num" size="10" value="#Ticket_num#"></font></td>
<td><font size=2><input type="select" name="Title" size="25" value="#Title#"></font></td>
<td><font size=2><input type="text" name="Network" size="15" value="#Network#"></font></td>
<td><font size=2><input type="text" name="Assigned_To" size="25" value="#Assigned_To#"></font></td>
<td><font size=2><input type="text" name="Customer" size="25" value="#Customer#"></font></td>
<td><font size=2><input type="text" name="Opened_Date" size="15" value="#DateFormat(Opened_Date,'mm/dd/yyyy')#"></font></td>
<td><font size=2><input type="text" name="Closed_Date" size="15" value="#DateFormat(Closed_Date,'mm/dd/yyyy')#"></font></td>
<td><font size=2><input type="text" name="Status" size="15" value="#Status#"></font></td>
<td><font size=2><input type="text" name="Priority" size="15" value="#Priority#"></font></td>
<td><font size=2><input type="text" name="Description" size="30" value="#Description#"></font></td>
<td><font size=2><input type="text" name="Date_Completed" size="15" value="#Date_Completed#"></font></td>
<td><font size=2><input type="text" name="Comments" size="50" value="#Comments#"></font></td>
</tr>

</CFOUTPUT>

<CFELSE>

<!-- This is where all the data get's nicely output into the table -->

<cfoutput>
<tr>
<td><font size=2>#Ticket_num#</font></td>
<td><font size=2>#Title#</font></td>
<td><font size=2>#Network#</font></td>
<td><font size=2>#Assigned_To#</font></td>
<td><font size=2>#Customer#</font></td>
<td><font size=2>#DateFormat(Opened_Date,'mm/dd/yyyy')#</font></td>
<td><font size=2>#DateFormat(Closed_Date,'mm/dd/yyyy')#</font></td>
<td><font size=2>#Status#</font></td>
<td><font size=2>#Priority#</font></td>
<td><font size=2>#Description#</font></td>
<td><font size=2>#Date_Completed#</font></td>
<td><font size=2>#Comments#</font></td>
<td>
</td>
</tr>
</CFOUTPUT>

</CFIF>

</CFLOOP>

</CFIF>

<!-- If URL.From is undefined -->

<CFELSE>

<CFOUTPUT QUERY="all">
<tr bgcolor="###iif(currentrow MOD 2,DE('ffffff'),DE('efefef'))#">
<td><font size=2>#Ticket_num#</font></td>
<td><font size=2>#Title#</font></td>
<td><font size=2>#Network#</font></td>
<td><font size=2>#Assigned_To#</font></td>
<td><font size=2>#Customer#</font></td>
<td><font size=2>#DateFormat(all.Opened_Date,'mm/dd/yyyy')#</font></td>
<td><font size=2>#DateFormat(all.Closed_Date,'mm/dd/yyyy')#</font></td>
<td><font size=2>#Status#</font></td>
<td><font size=2>#Priority#</font></td>
<td><font size=2>#Description#</font></td>
<td><font size=2>#Date_Completed#</font></td>
<td><font size=2>#Comments#</font></td>

<!-- This is where the Edit button and form is created -->

<td>
<form action="mysrs.cfm?user_name=#url.user_name#&From=Edit&ID=#Ticket_num#" method="post">
<input type="submit" value="Edit">
</form>
</td>

</tr>
</CFOUTPUT>

</CFIF>

<!-- If URL.From is defined and equals Edit, then display an update button and close the form -->

<CFIF IsDefined("URL.From")>
<CFIF #URL.From# IS "Edit">

<tr>
<td colspan="3">
<CFOUTPUT>
<input type="hidden" name="Ticket_num" value="#URL.ID#">
</CFOUTPUT>
<input type="submit" value="Update">
</form>
</td>
</tr>

</CFIF>
</CFIF>

</table>

</body>

Open in new window

0
jslaught
Asked:
jslaught
1 Solution
 
gdemariaCommented:
You have a lot of nested CFIF tags, you have a FORM tag that is actually split with the start of the form in the middle of the page and the end of the form inside a CFIF elsewhere down the bottom.   This is probably the cause of confusion, you can probably do that a cleaner-way.

In any case, the error is in a portion of code that you are not showing.   Probably the form action page mysrs.cfm.  So it's hard to know what variable is the problem, but it seems that the CFQUERYPARAM tag that is throwing the error is using the variable "Ticket_num"  (just a guess).    If you look, you will see that Ticket_num has two input tags.  So the value is going over twice.  That is what is causing the 18,18     The first Ticket_num tag is in the upper part of the form, the 2nd one is in the lower part of the form.

You need to remove one fo these.

Also, if the Ticket_num is empty, the CFQUERYPARAM will throw an error because empty "" is not an INTEGER.   You can get around this by wrapping ticket number in the val() function

<cfqueryparam value="#val(form.Ticket_num)#" type=".....

0
 
jslaughtAuthor Commented:
took suggestions and cleaned up code while combing through code line by line and figuring out the solution suggested. Thanks much!
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now