• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Inserting a record, not working. Please help

Participant ,
Feb 11, 2009 Feb 11, 2009

Copy link to clipboard

Copied

Hello;
I am stumped. I am trying to get this code to insert a new record, but when it goes through the code, it loses the record and doesn't insert it to the db. What am I missing? I can't figure it out.

My code:

<cfif isDefined("Form.newEdit_OK")>

<cfif isDefined("Form.RecordID")>
here is my query if it is updating and existing record
<cfelse>
<cfquery datasource="#APPLICATION.dataSource#" dbtype="ODBC">
INSERT INTO news
(title, newsDate, htmlList)
VALUES (<cfqueryparam cfsqltype="cf_sql_varchar" value="#form.title#">,
<cfqueryparam cfsqltype="cf_sql_date" value="#form.newsDate#">,
<cfqueryparam cfsqltype="cf_sql_longvarchar" value="#form.body#">)
</cfquery>
<cflocation url="news_RecordView.cfm">
</cfif>

What did I miss? I can't figure it out.

CFmonger
TOPICS
Advanced techniques

Views

462

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Feb 11, 2009 Feb 11, 2009
I troubleshoot if/else problems like this:

<cfif something>
true
<cfelse>
false
<cfdump something>
</cfif>

Votes

Translate

Translate
LEGEND ,
Feb 11, 2009 Feb 11, 2009

Copy link to clipboard

Copied

what type of form field is RecordID?
if it is a text/hidden field - it will ALWAYS be defined in the form.
hence the <cfelse> part of your code will never execute...

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Feb 11, 2009 Feb 11, 2009

Copy link to clipboard

Copied

this is the way my form is set up:

<form action="Action.cfm" method="post" name="news" id="news" onsubmit="saveIt()">
<input type="hidden" name="FieldList" value="#FormFieldList#">
<cfif isDefined("URL.RecordID")>
<input type="hidden" name="RecordID" value="#URL.RecordID#">
<input type="hidden" name="ID" value="#URL.RecordID#">
</cfif>
All my form fields are here
</form>

It should work.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 11, 2009 Feb 11, 2009

Copy link to clipboard

Copied

I troubleshoot if/else problems like this:

<cfif something>
true
<cfelse>
false
<cfdump something>
</cfif>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Feb 11, 2009 Feb 11, 2009

Copy link to clipboard

Copied

I used ths:
<cfdump var="#title#">

Did I write this correctly or go after the proper variable?
It just posted the title on a blank page. The title was from the form I am posting with. So it seems to be getting the variables to this point, it is something in my insert. Right?

Thanks for the help.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Feb 11, 2009 Feb 11, 2009

Copy link to clipboard

Copied

LATEST
I figured it out. my partner was messing with the db and changed the tales. so it wasn't putting info into the db. Thank you for all your help. I am sorry, it was something so obvious.

CFmonger

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation