Skip to main content
Inspiring
November 27, 2012
Question

Problem with insert statement.

Can someone tell me what is wrong with this code? I'm getting a too few parameters expected 4 error.

<cfquery datasource="poll" name="registration">

          INSERT INTO Members(login,password,first_name,last_name,email,phone,address)

        VALUES ("#form.username#","#pw#","#form.firstname#","#form.lastname#","#form.email#","#form.phone#","#form.address#")

    </cfquery>

All database fields are text even for the phone number and password.

This topic is closed to new replies. Start a new post to keep the conversation going.

2 replies

BKBK
Community Expert
Community Expert
November 27, 2012

Use single quotes in place of double quotes.

Translate
BKBK
Community Expert
Community Expert
November 27, 2012

Even better, use cfqueryparam thus:

... VALUES (<cfqueryparam value="#form.username#"  cfsqltype="cf_sql_varchar"> , <cfqueryparam value="#pw#"  cfsqltype="cf_sql_varchar">,...etc)

Translate