View Full Version : Help, please with this error: Incorrect syntax near '='
chrisjchrisj
02-25-2008, 03:17 AM
Could you please help me with this error? thanks
Microsoft OLE DB Provider for SQL Server error '80040e14'
Line 1: Incorrect syntax near '='.
/home/register_2.asp, line 80
(line 80 is: RS.Open SQL, MyConn)
These are lines 76 thru 92:
SQL = "SELECT fldSINCE, fldEXPIRES, fldUNIT FROM mms_tbl_user WHERE ID = " & Session("PMMS_ID")
Set RS = Server.CreateObject("ADODB.Recordset")
RS.LockType = 1
RS.CursorType = 0
RS.Open SQL, MyConn
IF NOT RS.EOF THEN
USER_SINCE = trim(RS("fldSINCE"))
USER_EXP = trim(RS("fldEXPIRES"))
USER_UNIT = trim(RS("fldUNIT"))
END IF
RS.Close
Set RS = Nothing
MyConn.Close
Set MyConn = Nothing
END IF
Roelf
02-25-2008, 08:06 AM
did you check which value is in the session("pmms_id")? What is the type of the id column in the database? Is it numeric or text?
Can you response.write the query before you execute it? Post the results here and we can see what is wrong.
chrisjchrisj
02-25-2008, 06:35 PM
Thanks for your reply.
I added:
response.write(sql)
response.end
before line 80
and this is what shows instead of the error:
SELECT fldSINCE, fldEXPIRES, fldUNIT FROM mms_tbl_user WHERE ID =
I don't know what to do next with this information. Can you help me please?
Thanks
Roelf
02-26-2008, 10:14 AM
Thanks for your reply.
I added:
response.write(sql)
response.end
before line 80
and this is what shows instead of the error:
SELECT fldSINCE, fldEXPIRES, fldUNIT FROM mms_tbl_user WHERE ID =
I don't know what to do next with this information. Can you help me please?
Thanks
You see that the query is incomplete. There is no value to match the ID column with. Make sure your Session var is filled before you execute the query. Where do you fill the session var?
chrisjchrisj
02-29-2008, 04:52 AM
Thank you so much for your reply.
I'm afraid I don't know the answer to "Where do you fill the session var"?
Can you guide me to where that might be?
Thanks
Also, I ran it again with response.write(sql) and response.end in the file and this time instead of seeing the error, I see this:
SELECT fldSINCE, fldEXPIRES, fldUNIT FROM mms_tbl_user WHERE ID = 118
Could this information help you help me resolve this error issue?
Thanks
Roelf
02-29-2008, 11:22 AM
Somewhere in the code is a line which says:
Session("PMMS_ID") = .....
This value is kept inside this sessionvariable to be used in the query. In the new situation, there is indeed a value present. So the problem is not in this query, it is in the moment where the session variable is filled. It seems that sometimes it is filled, and sometimes it is not.
When there is a value, the sql will not fail (i guess). So it is time to find out how and when this session variable is filled. As this is a variable which will keep its value while browsing through different pages in your site, the place where it is filled, can easily be in another page. So you have to find out a way to make sure the var is filled before the page with the query is executed.
chrisjchrisj
02-29-2008, 06:37 PM
Thanks for your reply.
Could the variable possible be set on this login page code?:
<!--#include file="inc_header.asp"-->
<!--#include file="app_config.asp"-->
<!--#include file="inc_api.asp"-->
<%Dim sMODE, sUSERNAME, sPASSWORD, sMESSAGE, sRS, sSQL, sID, sSINCE, sEXPIRES, sNAME, sREM, sREF, sLOGOUT, _
sVALID, sACTIVE, sMEM_RED, GROUP_REDIR, strG_IDS, blSTEP_TWO, ADD_MSG
' COLLECT FORM INPUT
With Request
sMODE = APO(.Form("mode"))
sLOGOUT = APO(.QueryString("logout"))
End With
' LOGOUT IF REQUESTED
IF sLOGOUT = "True" THEN
Call OPEN_DB()
Call RETURN_VALUE(False)
IF Session("PMMS_IN") = "True" THEN
Call APPEND_LOG(False, Session("PMMS_ID"), "Logs out.", Trim(sysVAL(7)))
END IF
MyConn.close
Set MyConn = Nothing
Session.Abandon
Response.Redirect LOG_OUT_URL
Response.end
END IF
' PROCESS LOGIN
IF sMODE = "login" THEN
With Request
sUSERNAME = APO(.Form("username"))
sPASSWORD = APO(.Form("password"))
sREM = Trim(.Form("rem"))
sREF = STRIP_CODE(APO(.Form("ref_page")))
End With
Call CHECK_INPUT()
IF sMESSAGE = "" THEN
Call OPEN_DB()
Call RETURN_VALUE(False)
ADD_MSG = " You can contact us at <a href='mailto:" & sysVAL(12) & "'>" & sysVAL(12) & "</a> if you have any questions.<br>"
IF sysVAL(21) = "1" THEN sMESSAGE = "Sorry, the member login has been temporarily disabled. Please try again later." & ADD_MSG
SQL = "SELECT ID, fldSINCE, fldEXPIRES, fldNAME, fldVALID, fldCHAR, fldACTIVE, fldSTATUS, fldREDIRECT FROM mms_tbl_user WHERE (fldUSERNAME='" & sUSERNAME & "') AND (fldPASSWORD='" & sPASSWORD & "')"
Set sRS = Server.CreateObject("ADODB.Recordset")
sRS.Open SQL, MyConn
IF NOT sRS.EOF THEN
sID = trim(sRS("ID"))
sSINCE = trim(sRS("fldSINCE"))
sEXPIRES = trim(sRS("fldEXPIRES"))
sNAME = trim(sRS("fldNAME"))
sVALID = trim(sRS("fldVALID"))
sACTIVE = trim(sRS("fldACTIVE"))
sSTATUS = trim(sRS("fldSTATUS"))
sMEM_RED = trim(sRS("fldREDIRECT"))
ELSE
sMESSAGE = sMESSAGE & "<li />This is not a currently valid username and password combination."
END IF
sRS.Close
Set sRS = Nothing
IF sMESSAGE = "" THEN
IF sMESSAGE = "" THEN IF NOT (sSTATUS = Trim(drpSTATUS(0)) OR sSTATUS = Trim(drpSTATUS(5)) OR sSTATUS = Trim(drpSTATUS(3))) THEN sMESSAGE = sMESSAGE & "<li />Sorry, your status is <i>" & sSTATUS & "</i>." & ADD_MSG
IF sSTATUS = Trim(drpSTATUS(3)) THEN
Session( "sUSER_ID" ) = sID
Session("PMMS_USERNAME") = sUSERNAME
Session("PMMS_NAME") = sNAME
Session("PMMS_TEMP_IN") = "True"
sMESSAGE = sMESSAGE & "ACCOUNT STATUS: " & sSTATUS & "<br><br>"
END IF
IF DateDiff("d", Date(),Cdate(FormatDateTime(CDate(sSINCE),2))+Cdbl(sEXPIRES)) =< 0 THEN sMESSAGE = sMESSAGE & Replace(RETURN_TEMPLATES(False,"fldMSG4",True),"%name%",sNAME)
IF Trim(sysVAL(1)) = "1" THEN ' Requires user email authentication
IF NOT sVALID = "1" THEN
sMESSAGE = sMESSAGE & "<li />You must verify your registration profile via the link emailed to you.<br /> Please click <a href='resend.asp?ID=" & sID & "'><b>here</b></a> to have the validation email resent." & ADD_MSG
END IF
END IF
IF Trim(sysVAL(1)) = "3" THEN ' Requires admin authentication
IF NOT sVALID = "1" THEN
sMESSAGE = sMESSAGE & "<li />Your profile has not been activated by an administrator, please try again later." & ADD_MSG
END IF
END IF
IF sMESSAGE = "" THEN IF NOT sACTIVE = "1" THEN sMESSAGE = sMESSAGE & "<li />Sorry, your profile is not active." & ADD_MSG
IF sSTATUS = Cstr(drpSTATUS(5)) THEN blSTEP_TWO = "True"
IF sMESSAGE = "" THEN
' UPDATE SOME USER INFO
Call UPDATE_INFO(False, sID, Trim(sysVAL(8)))
if blSTEP_TWO = "True" THEN
Call APPEND_LOG(False, sID, "Member is asked to make a payment.", Trim(sysVAL(7)))
else
Call APPEND_LOG(False, sID, "Logs in @ " & APO(Request.ServerVariables("PATH_INFO")), Trim(sysVAL(7)))
end if
IF MMS_BACKEND = "1" THEN
SQL = "UPDATE mms_tbl_user SET fldLAST_LOGIN = GetDate() WHERE ID =" & sID
ELSE
SQL = "UPDATE mms_tbl_user SET fldLAST_LOGIN = Now() WHERE ID =" & sID
END IF
MyConn.Execute(SQL)
' GET GROUP REDIR
IF MMS_BACKEND = 3 THEN
SQL = "SELECT fldREDIRECT FROM mms_tbl_cate INNER JOIN mms_tbl_user_cate ON mms_tbl_cate.ID = mms_tbl_user_cate.fldCATE_ID WHERE mms_tbl_user_cate.fldUSER_ID = " & sID
ELSE
SQL = "SELECT TOP 1 fldREDIRECT FROM mms_tbl_cate WHERE ID IN (SELECT TOP 1 fldCATE_ID FROM mms_tbl_user_cate WHERE fldUSER_ID = " & sID & " ORDER BY fldCATE_ID ASC)"
END IF
Set RS = Server.CreateObject("ADODB.Recordset")
RS.Open SQL, MyConn
IF NOT RS.EOF THEN
GROUP_REDIR = trim(RS("fldREDIRECT"))
END IF
RS.Close
Set RS = Nothing
' GET GROUP ID's
SQL = "SELECT fldCATE_ID FROM mms_tbl_user_cate WHERE fldUSER_ID = " & sID & " ORDER BY fldCATE_ID ASC"
Set RS = Server.CreateObject("ADODB.Recordset")
RS.LockType = 1
RS.CursorType = 0
RS.Open SQL, MyConn
WHILE NOT RS.EOF
strG_IDS = strG_IDS & trim(RS("fldCATE_ID")) & ";"
RS.MoveNext
WEND
RS.Close
Set RS = Nothing
END IF
END IF
MyConn.Close
Set MyConn = Nothing
' MEMBER IS YET TO PAY, OR HIS ACCOUNT IS SET TO "Unpaid Account"
IF blSTEP_TWO = "True" THEN
Session.Timeout = 25
Session("PMMS_USERNAME") = sUSERNAME
Session("PMMS_NAME") = sNAME
Session("PMMS_ID") = sID
Session("PMMS_TEMP_IN") = "True"
Response.Redirect "_register_2.asp?M=1"
Response.End
END IF
' SET SESSION VARIABLES FOR THE USER
IF sMESSAGE = "" THEN
IF sREM = "1" THEN
Response.Cookies("USERNAME") = sUSERNAME
Response.Cookies("USERNAME").Expires = Date() + 35
ELSE
Response.Cookies("USERNAME") = ""
Response.Cookies("USERNAME").Expires = Date() + 35
END IF
Session.Timeout = 25
Session("PMMS_USERNAME") = sUSERNAME
Session("PMMS_NAME") = sNAME
Session("PMMS_ID") = sID
Session("PMMS_GIDS") = strG_IDS
Session("PMMS_IN") = "True"
' // HD ADDITION
Session("MMS_HD_U") = EnCrypt(sUSERNAME)
Session("MMS_HD_P") = EnCrypt(sPASSWORD)
' REDIRECT TO THE REFERING PAGE (or profile.asp if the ref. page is missing)
' ( sMEM_RED = Member Redirection ; GROUP_REDIR = Group Redirection)
SELECT CASE REDIRECTION_MODE
CASE "2" ' [ Member Individual Redirection ]
IF NOT (sMEM_RED = "" OR IsNull(sMEM_RED)) THEN
sREF = sMEM_RED
ELSE
IF sREF = "" Or IsNULL(sREF) THEN
sREF = "profile.asp"
ELSE
sREF = DOMAIN_URL & sREF
END IF
END IF
CASE "3" ' [ Redirection URL of First Member Assigned Group ]
IF NOT (GROUP_REDIR = "" OR IsNull(GROUP_REDIR)) THEN
sREF = GROUP_REDIR
ELSE
IF sREF = "" Or IsNULL(sREF) THEN
sREF = "profile.asp"
ELSE
sREF = DOMAIN_URL & sREF
END IF
END IF
CASE "4" ' [ Member OR Group OR Requested Page Redirection ]
IF NOT (sMEM_RED = "" OR IsNull(sMEM_RED)) THEN
sREF = sMEM_RED
ELSE
IF NOT (GROUP_REDIR = "" OR IsNull(GROUP_REDIR)) THEN
sREF = GROUP_REDIR
ELSE
IF sREF = "" Or IsNULL(sREF) THEN
sREF = "profile.asp"
ELSE
sREF = DOMAIN_URL & sREF
END IF
END IF
END IF
CASE ELSE ' [ ORIGINALLY REQUEST PAGE ]
IF sREF = "" Or IsNULL(sREF) THEN
sREF = "profile.asp"
ELSE
sREF = DOMAIN_URL & sREF
END IF
END SELECT
Response.Redirect sREF
Response.End
END IF ' { IF sMESSAGE = "" THEN }
END IF ' { IF sMESSAGE = "" THEN }
ELSE
Call RETURN_VALUE(True)
IF sysVAL(21) = "1" THEN sMESSAGE = "Sorry, the member login has been temporarily disabled. Please try again later." & ADD_MSG
END IF ' { IF sMODE = "login" THEN }
' CHECK THE LOGIN INFO
PRIVATE SUB CHECK_INPUT()
IF sUSERNAME = "" OR IsNUll(sUSERNAME) THEN sMESSAGE = sMESSAGE & "<li />Please enter your username."
IF sPASSWORD = "" OR IsNUll(sPASSWORD) THEN sMESSAGE = sMESSAGE & "<li />Please enter your password."
IF sMESSAGE = "" THEN
IF Len(sUSERNAME) < 5 THEN sMESSAGE = sMESSAGE & "<li />Username must be between 5 and 25 characters."
IF Len(sPASSWORD) < 5 THEN sMESSAGE = sMESSAGE & "<li />Password must be between 5 and 25 characters."
END IF
END SUB
%>
<% IF NOT sMESSAGE = "" THEN %>
<!--#include file="inc_error.asp"-->
<!--#include file="inc_footer.asp"-->
<% Response.End %>
<% END IF %>
<!-- IF the user is logged in, then show this message -->
<% IF Session("PMMS_IN") = "True" THEN %>
<table width="500" align="center" cellpadding="2" cellspacing="0" border="1" bordercolor="WhiteSmoke">
<tr bgcolor="WhiteSmoke">
<td>Success</td>
</tr><tr>
<td align="center">
<br />
You are successfully logged in.
<br /><br />
</td>
</tr></table>
<!--#include file="inc_footer.asp"-->
<% Response.End %>
<% END IF %>
<!-- [ IF the user is logged in, then show this message. ] -->
<!-- LOGIN FORM START -->
<br />
<form action="login.asp" method="post" name="frm" onSubmit="return ValidateLogin()">
<table align="center" cellpadding="2" cellspacing="0" border="0"><tr>
<td width="110">Your Username:</td>
<td width="190"><input style="width: 100%;" class="textbox" type="Text" name="username" value="<%=Trim(Request.Cookies("USERNAME"))%>" maxlength="25" size="20" /></td>
</tr><tr>
<td>Your Password:</td>
<td><input style="width: 100%;" class="textbox" type="Password" name="password" value="" maxlength="25" size="20" /></td>
</tr><tr>
<td><input type="Checkbox" name="rem" value="1"<%If NOT Trim(Request.Cookies("USERNAME")) = "" Then%> checked<%End If%> />Save Username</td>
<td align="right"><input style="width: 100%;" type="Submit" value="Login Now" /></td>
</tr><tr>
<td colspan="2"><Br><Br>
<a href="reminder.asp">Password Reminder</a>,
<a href="register.asp">New Account Registration</a><Br>
</td>
</tr></table>
<input type="Hidden" name="mode" value="login" />
<input type="Hidden" name="ref_page" value="<%=STRIP_CODE(Request.QueryString("ref_page"))%>" />
</form>
<br />
<!-- LOGIN FORM END -->
<!--#include file="inc_footer.asp"-->
Roelf
03-02-2008, 09:32 AM
Yes, the Session("PMMS_ID") is set on this page, but there are probably conditions where it is not set. I don't know the logic of this page, but you probably can try to find out in which case the var is set and in which case it isn't. Another possibility is that the session has expired between the setting of the var and the execute of the query. Mostly the session expires after 20 minutes, but that could have been altered. If the session expires, all sessionvars lose their value
chrisjchrisj
03-03-2008, 12:50 AM
Someone who looked at the files told me:
"the problem is with that session variable disappearing"
Can you tell me how this might happen and how it might be solved?
thanks.
DigitalFusion
03-03-2008, 09:58 PM
the session times out?
application pools are being recycled?
not maintaining state between links?
Roelf
03-05-2008, 08:36 AM
session times out after 25 minutes. THis could be the cause. Also, there is an id fetched from a database, are all members id's filled properly in the database? A lot of IF THEN ELSE going on in that page, probably there are scenario's where the session var is not set. I have tried to wade through to find all causes where the var is not set, but i don't have time for deep analysis.
Try setting the session timeout at a higher value, see if that solves the error. Session.timeout is set twice in that code, so be sure you change both values
chrisjchrisj
03-05-2008, 08:12 PM
Thanks for all of your help. I greatly appreciate it.
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.