ColdFusion Programming/Assistance with a Form

Advertisement


Question
This is my coding:

<cfquery name="Add" datasource="library">
INSERT INTO Authors (AuthLast, AuthFirst, PublishedWorks, Publisher, PubDate, Price, ISBN)
VALUES ('#Form.AuthLast#',
  '#Form.AuthFirst#',
  '#Form.PublishedWorks#',
  '#Form.Publisher#',
   #Form.PubDate#,
   #Form.Price#,
   #Form.ISBN#)
</cfquery>

The problem that I'm having is that I get the following error:

Element PUBLISHER is undefined in FORM.

Answer
It means that the field 'Publisher' in your form is null or empty. Make sure that form field has a value or go back to the 'Authors' table in your database and change it to 'Allow Null' for that field and any other fields you'll allow to be empty on insert.

Also, please use the <cfqueryparam> tag to set your values in your insert statement. It's just standard coding practice to use it, especially for forms where you might get attacked.

ColdFusion Programming

All Answers


Answers by Expert:


Ask Experts

Volunteer


Clint Willard

Expertise

I will volunteer to answer your Coldfusion programming questions.

Experience

I am an expert certified Coldfusion MX programmer with experience in Flash, Action Script, Flex, SQL, XML, and other related.

Education/Credentials
Associates in Applied Science and Coldfusion MX certificate.

©2012 About.com, a part of The New York Times Company. All rights reserved.