Question
Query problem again
Will I ever get this!
I have a form template which runs fine (it registers a user of my discussino board):
<h2>Register here to post comments to any forum on this site </h2>
<form action="Education - Bulletin Board - Register - code.cfm" method="post">
<p>
<strong>Username: </strong>
<input type="text" name="user" />
</p>
<p><br />
<strong>Password: </strong>
<input type="password" name="pass" />
</p>
<p><br />
<strong>Your mother's maiden name (a security precaution if you forget your username/password and need to retrieve them): </strong>
<input type="text" name="MaidenName" />
</p>
<p><br />
<strong>Email address (optional - in case I need to contact you about your posts): </strong>
<input type="text" name="email" />
</p>
<p><br />
<p>
<input type="submit" value="Register!" />
<input type="button" value="Back" onClick="self.location='index.cfm';" />
</p>
</form>
</body>
Now I want to check if the username and password have been taken by a previous user so I use this code:
<cfif NOT structIsEmpty(form)>
<cfquery name="CheckUserName" datasource= "Education Forum">
SELECT UserName, Count(UserName) as Duplicates
FROM ForumUsers
WHERE ForumUsers.UserName=#form.user#
GROUPBY ForumUsers.UserName
</cfquery>
<cfquery name="CheckPassword" datasource= "Education Forum">
SELECT PassWord, Count(PassWord) as Duplicates
FROM ForumUsers
WHERE ForumUsers.Password=#form.PassWord#
GROUPBY Password
</cfquery>
I just count how many times the password has been used. If it has been used more than once I'll later ask the new user to enter a different password. Unfortunately, Coldfusion has a problem with this query. Specifically, it gives me the error:
Access Driver] Syntax error (missing operator) in query expression 'ForumUsers.UserName=jimmy GROUPBY ForumUsers.UserName'.
The Error Occurred in C:\CFusionMX\wwwroot\Education\Bulletin Board\Education - Bulletin Board - Register - code.cfm: line 7
5 : WHERE ForumUsers.UserName=#form.user#
6 : GROUPBY ForumUsers.UserName
7 : </cfquery>
8 : <cfquery name="CheckPassword" datasource= "Education Forum">
9 : SELECT PassWord, Count(PassWord) as Duplicates
SQL SELECT UserName, Count(UserName) as Duplicates FROM ForumUsers WHERE ForumUsers.UserName=jimmy GROUPBY ForumUsers.UserName
DATASOURCE Education Forum
VENDORERRORCODE -3100
SQLSTATE 42000
I've run into this before, but I don't seem to be able to grasp the general principle involved.
I'd be very grateful if someone could explain the error in this particular case and how I can avoid the problem in the futre.
Thanks, once again, very much in advance.
I have a form template which runs fine (it registers a user of my discussino board):
<h2>Register here to post comments to any forum on this site </h2>
<form action="Education - Bulletin Board - Register - code.cfm" method="post">
<p>
<strong>Username: </strong>
<input type="text" name="user" />
</p>
<p><br />
<strong>Password: </strong>
<input type="password" name="pass" />
</p>
<p><br />
<strong>Your mother's maiden name (a security precaution if you forget your username/password and need to retrieve them): </strong>
<input type="text" name="MaidenName" />
</p>
<p><br />
<strong>Email address (optional - in case I need to contact you about your posts): </strong>
<input type="text" name="email" />
</p>
<p><br />
<p>
<input type="submit" value="Register!" />
<input type="button" value="Back" onClick="self.location='index.cfm';" />
</p>
</form>
</body>
Now I want to check if the username and password have been taken by a previous user so I use this code:
<cfif NOT structIsEmpty(form)>
<cfquery name="CheckUserName" datasource= "Education Forum">
SELECT UserName, Count(UserName) as Duplicates
FROM ForumUsers
WHERE ForumUsers.UserName=#form.user#
GROUPBY ForumUsers.UserName
</cfquery>
<cfquery name="CheckPassword" datasource= "Education Forum">
SELECT PassWord, Count(PassWord) as Duplicates
FROM ForumUsers
WHERE ForumUsers.Password=#form.PassWord#
GROUPBY Password
</cfquery>
I just count how many times the password has been used. If it has been used more than once I'll later ask the new user to enter a different password. Unfortunately, Coldfusion has a problem with this query. Specifically, it gives me the error:
Access Driver] Syntax error (missing operator) in query expression 'ForumUsers.UserName=jimmy GROUPBY ForumUsers.UserName'.
The Error Occurred in C:\CFusionMX\wwwroot\Education\Bulletin Board\Education - Bulletin Board - Register - code.cfm: line 7
5 : WHERE ForumUsers.UserName=#form.user#
6 : GROUPBY ForumUsers.UserName
7 : </cfquery>
8 : <cfquery name="CheckPassword" datasource= "Education Forum">
9 : SELECT PassWord, Count(PassWord) as Duplicates
SQL SELECT UserName, Count(UserName) as Duplicates FROM ForumUsers WHERE ForumUsers.UserName=jimmy GROUPBY ForumUsers.UserName
DATASOURCE Education Forum
VENDORERRORCODE -3100
SQLSTATE 42000
I've run into this before, but I don't seem to be able to grasp the general principle involved.
I'd be very grateful if someone could explain the error in this particular case and how I can avoid the problem in the futre.
Thanks, once again, very much in advance.
