-1

Please check my query below

<cfquery datasource="quackit" name="insertuser">
   INSERT INTO user (user_id, group_id)
   VALUES (#form.usr_id#,#form.access_flg#)
</cfquery>

But I am getting Error executing database query

I am able to fetch the data ,Please correct me where I am doing wrong

James A Mohler
  • 11,060
  • 15
  • 46
  • 72
Soujanya
  • 277
  • 4
  • 17
  • 6
    You'll need to provide the exact error details. If you can't see the details, [surround the code with a `cftry`/`cfcatch` and dump the error](http://www.learncfinaweek.com/week1/Error_Handling/) What type of database? MSSQL? MySQL? Something else? Don't make us guess. Also, always use `cfqueryparam` when passing parameters into a query. Not doing so will leave you highly vulnerable to SQL injection. – beloitdavisja Feb 18 '16 at 15:03

1 Answers1

2

Use cfqueryparam. You are wide open to sql injection right now. The error probably comes from one of your form variables being blank, which you will need to check for either way.

We can't give more precise advice without details on the specific database error. If it's not due to the form feeding in bad data, it has something to do with your database structure (perhaps you are trying to insert an invalid foreign key, or leaving off a required field).

Tim Jasko
  • 1,532
  • 1
  • 8
  • 12
  • Thanks for the reply Tim Jasko,I am getting form data correctly ,I am able to see the data ,And before inserting data into database ,I am doing select query for that,If I haven't find any thing then only I am calling insert query.How can I find proper error message . – Soujanya Feb 18 '16 at 17:06