ColdFusion Programming/Assistance with a Form
Expert: Clint Willard - 1/24/2009
QuestionThis 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.
AnswerIt 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.