Skip to main content
Inspiring
August 8, 2010
Question

update record form

  • August 8, 2010
  • 1 reply
  • 493 views

Hi, I'm trying to update a record and I keep getting an error that says pm_id is not defined in rsPmUpdate but I'm pretty sure it is.  I'm using Dreamweaver CS4 to create the update form.  Maybe it has something to do with what happens when I try to preview it-- when I try to preview it, I get a pop up that says:

Update Copy oin Testing Server?

This will update the file on testing server.

This might affect others working on the file.  Proceed?

I was kind of scared to do it, but I clicked 'yes' but then was given another pop up:

Dependent Files

Put dependent files?

YOu can change this preferencde in the Site category of the preferences dialog.

What do those messages mean? They sound like they might mess with my site or database.

The file is called pmUpdateFORM.cfm.  When I test my recordset with a test value, it shows that it is working correctly, and when I preview in firefox I add '?pm_id=(a number).

This is the code:

<cfset CurrentPage=GetFileFromPath(GetBaseTemplatePath())>
<cfif IsDefined("FORM.MM_UpdateRecord") AND FORM.MM_UpdateRecord EQ "form1">
  <cfquery datasource="mymindsnotrighttest">  
    UPDATE privatemessages
SET sender_id=<cfif IsDefined("FORM.sender_id") AND #FORM.sender_id# NEQ "">
<cfqueryparam value="#FORM.sender_id#" cfsqltype="cf_sql_numeric">
<cfelse>
NULL
</cfif>
, sent_to_id=<cfif IsDefined("FORM.sent_to_id") AND #FORM.sent_to_id# NEQ "">
<cfqueryparam value="#FORM.sent_to_id#" cfsqltype="cf_sql_numeric">
<cfelse>
NULL
</cfif>
, pmtitle=<cfif IsDefined("FORM.pmtitle") AND #FORM.pmtitle# NEQ "">
<cfqueryparam value="#FORM.pmtitle#" cfsqltype="cf_sql_clob" maxlength="65535">
<cfelse>
''
</cfif>
, pmcontent=<cfif IsDefined("FORM.pmcontent") AND #FORM.pmcontent# NEQ "">
<cfqueryparam value="#FORM.pmcontent#" cfsqltype="cf_sql_clob" maxlength="2147483647">
<cfelse>
''
</cfif>
, read=<cfif IsDefined("FORM.read") AND #FORM.read# NEQ "">
<cfqueryparam value="#FORM.read#" cfsqltype="cf_sql_clob" maxlength="65535">
<cfelse>
''
</cfif>
, date=<cfif IsDefined("FORM.date") AND #FORM.date# NEQ "">
<cfqueryparam value="#FORM.date#" cfsqltype="cf_sql_timestamp">
<cfelse>
NULL
</cfif>
, sender_username=<cfif IsDefined("FORM.sender_username") AND #FORM.sender_username# NEQ "">
<cfqueryparam value="#FORM.sender_username#" cfsqltype="cf_sql_clob" maxlength="65535">
<cfelse>
''
</cfif>
WHERE pm_id=<cfqueryparam value="#FORM.pm_id#" cfsqltype="cf_sql_numeric">
  </cfquery>
  <cflocation url="pmReadTABLE.cfm">
</cfif>
<form name="form1" method="POST" action="<cfoutput>#CurrentPage#</cfoutput>">
  <table width="75%" border="0" cellpadding="4">
    <tr>
      <td width="13%">pm_id</td>
      <td width="87%"><cfoutput>#rsPmUpdate.pm_id#</cfoutput>        <input name="pm_id" type="hidden" id="pm_id" value="<cfoutput>#rsPmUpdate.pm_id#</cfoutput>"></td>
    </tr>
    <tr>
      <td>sender_id</td>
      <td><label>
        <input name="sender_id" type="text" id="sender_id" value="<cfoutput>#rsPmUpdate.sender_id#</cfoutput>">
      </label></td>
    </tr>
    <tr>
      <td>sent_to_id</td>
      <td><label>
        <input name="sent_to_id" type="text" id="sent_to_id" value="<cfoutput>#rsPmUpdate.sent_to_id#</cfoutput>">
      </label></td>
    </tr>
    <tr>
      <td>pmtitle</td>
      <td><label>
        <input name="pmtitle" type="text" id="pmtitle" value="<cfoutput>#rsPmUpdate.pmtitle#</cfoutput>">
      </label></td>
    </tr>
    <tr>
      <td>pmcontent</td>
      <td><label>
        <textarea name="pmcontent" id="pmcontent" cols="45" rows="5"><cfoutput>#rsPmUpdate.pmcontent#</cfoutput></textarea>
      </label></td>
    </tr>
    <tr>
      <td>read</td>
      <td><label>
        <input name="read" type="text" id="read" value="<cfoutput>#rsPmUpdate.read#</cfoutput>">
      </label></td>
    </tr>
    <tr>
      <td>date</td>
      <td><label>
        <input name="date" type="text" id="date" value="<cfoutput>#rsPmUpdate.date#</cfoutput>">
      </label></td>
    </tr>
    <tr>
      <td>sender_username</td>
      <td><label>
        <input name="sender_username" type="text" id="sender_username" value="<cfoutput>#rsPmUpdate.sender_username#</cfoutput>">
      </label></td>
    </tr>
    <tr>
      <td> </td>
      <td><label>
        <input type="submit" name="submit" id="submit" value="Submit">
      </label></td>
    </tr>
  </table>
  <input type="hidden" name="MM_UpdateRecord" value="form1">
</form>
<cfparam name="URL.pm_id" default="1">
<cfquery name="rsPmUpdate" datasource="mymindsnotrighttest">
SELECT *
FROM privatemessages
WHERE pm_id = <cfqueryparam value="#URL.pm_id#" cfsqltype="cf_sql_numeric">
</cfquery>

    This topic has been closed for replies.

    1 reply

    Inspiring
    August 9, 2010

    Hi,

    If you dont want the Dreamweaver to update your dependent files, Just go to the "Edit -> Preferences" menu, In the preferences dialog click on the "Site" category which can be seen in the left panel, and there you might have some options for setting the "Dependent files" preferences, just check out the "Get/Check Out" and "Prompt on Put/Check" options.

    I hope this might fix your issue.

    HTH

    wycksAuthor
    Inspiring
    August 9, 2010

    Thanks for the response.  Are those settings that need to be changed the reason the update form hasn't been working?

    Inspiring
    August 9, 2010

    Those settings are probably not the source of your errors.

    Your first cfquery does not have a name.  That will cause an error, but not the one you described.  You described an error as "element whatever not defined in somequery".  Since you say the field was included in the query, then the query doesn't exist.  This is probably due to some if/else code somewhere.  However, when I quickly glanced at your code, I didn't see any attempt to reference that field.