Skip to main content
Participant
September 8, 2008
Question

Inser then query

  • September 8, 2008
  • 1 reply
  • 934 views
I am doing an insert then trying to put the id of that query into a COOKIE.

I am getting an "Element APP_ID is undefined in Q_APP_ID" error from this code.

<cfquery name="q_enter_app_info" datasource="xxxxxxxx" username="xxxxxxxx" password="xxxxxxxx">

INSERT INTO `app_information`
(`app_id`, `app_first`, `app_last`, `app_dob`, `app_address`, `app_city`, `app_state`, `app_zip`, `app_phone`, `app_email`, `app_member`, `app_date`)
VALUES
(NULL, '#first#', '#last#','#DateFormat(dob, "yyyy-mm-dd")#', '#address#', '#city#', '#state#', '#zip#', '#phone#', '#email#', '#member#', '#DateFormat(date, "yyyy-mm-dd")#')
</cfquery>

<cfquery name="q_app_id" datasource="xxxxxxxx" username="xxxxxxxx" password="xxxxxxxx">
SELECT *
FROM app_information
WHERE app_phone = #phone#
</cfquery>

<cfcookie name="app_id" value="#q_app_id.app_id#">

Can someone knows how to make this code work or can show me an easier way to do it.
This topic has been closed for replies.

1 reply

Inspiring
September 8, 2008
Could have something to do with the fact that you are inserting null into that field.

If you cfdump q_app_id right after you run that query, what do you see?
Participant
September 9, 2008
I am get the "Element APP_ID is undefined in Q_APP_ID" error, then it stops. The field that is getting the NULL is an auto increment field.
Inspiring
September 9, 2008
quote:

Originally posted by: womt
I am get the "Element APP_ID is undefined in Q_APP_ID" error, then it stops. The field that is getting the NULL is an auto increment field.

My guess is that you are trying to use that query result before you run the query. Either that or you have some if/else logic that prevents the query from running.

My reasons are:
Your query is missing quotes and would crash if Cold Fusion tried to run it.
Your cfdump did not show anything.