Go Back   CodingForums.com > :: Server side development > Other server side languages/ issues > ColdFusion

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 04-13-2012, 10:27 AM   PM User | #1
fvnbab
New to the CF scene

 
Join Date: Apr 2012
Posts: 5
Thanks: 1
Thanked 0 Times in 0 Posts
fvnbab is an unknown quantity at this point
Coldfusion help

the aim is for the client(fictious) to update their details
so i hav created 4 cfm pages
1st page to search for a member
2nd page is the results page
3rd page to update the details for example details such as name is update
4th page finaaaly update into my database and the message should come up as "member updated" All this pages are put on the server as well.
My problems are well first of all i can only edit one client out of 10 this code is in the 2nd page and the currrent code is

<cfquery name = "Recordset1" datasource = "b1008321-access">
SELECT * FROM Member WHERE first_name LIKE '%seth%'
</cfquery>
<html>
<head><title>Search for Member</title></head>
<body bgcolor="#FFFFFF">
<table border="1">
<tr><td>Member Name</td></tr>
<cfoutput query = "Recordset1">
<tr><td><a href = "memberupdate3.cfm?memberID=#memberID#"> #first_name#</a></td></tr>
</cfoutput>
</table>
</body>
</html>
i want to be able to search for all the clients not just one
And the other problem is on the 4th page error message comes up
Error Executing Database Query.

[Macromedia][SequeLink JDBC Driver][ODBC Socket][Microsoft][ODBC Microsoft Access Driver] Syntax error in UPDATE statement.
And the code i put for tht is

<cfquery datasource="b1008321-access">
UPDATE Member
SET first name='# FORM.first_name#', last name='# FORM.last_name#', address='# FORM.address#', Town='# FORM.Town#', date joined='# FORM.date_joined#'
WHERE memberID = #memberID#
</cfquery>
<html>
<body>
<h1>File Updated</h1></body>
</html>
fvnbab is offline   Reply With Quote
Old 04-14-2012, 07:21 PM   PM User | #2
Gjslick
Regular Coder

 
Join Date: Feb 2009
Location: NJ, USA
Posts: 476
Thanks: 2
Thanked 70 Times in 69 Posts
Gjslick will become famous soon enough
You have spaces in the column names in your query. You can't just have "first name", this confuses the query parser. That should be changed to either "firstName" or "first_name". A column name basically shouldn't have a space in it.

I highlighted the problems in red below:
Code:
<cfquery datasource="b1008321-access">
UPDATE Member
SET first name='# FORM.first_name#', last name='# FORM.last_name#', address='# FORM.address#', Town='# FORM.Town#', date joined='# FORM.date_joined#'
WHERE memberID = #memberID#
</cfquery>
I'd recommend losing the spaces, but if you *really* need to keep them, then you need to surround each column name that has spaces with square brackets in your query. For example, you could change your query to this: (with a little better formatting...)

Code:
<cfquery datasource="b1008321-access">
    UPDATE
        Member
    SET
        [first name] = '#FORM.first_name#',
        [last name] = '#FORM.last_name#',
        address = '#FORM.address#',
        Town = '#FORM.Town#',
        [date joined] = '#FORM.date_joined#'
    WHERE 
        memberID = #memberID#
</cfquery>

Last edited by Gjslick; 04-15-2012 at 06:17 PM.. Reason: Better formatting
Gjslick is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 01:49 AM.


Advertisement
Log in to turn off these ads.