If-sats, min vän:
If session("userid") <> "" then
' sessionsvariabeln [i]userid[/i] har ett värde, gör saker och ting
End if
mvh
7 svar · 338 visningar · startad av devotion
Hej !
Får följande fel:
HTTP 500.100 - Internt serverfel - ASP-fel
Internet Information Services--------------------------------------------------------------------------------
Teknisk information (för supportpersonal)
Feltyp:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
[Microsoft][Drivrutin för ODBC Microsoft Access] Syntaxfel (operator saknas) i frågeuttrycket 'userId ='.
/frames/bottomFrame.asp, line 28
Med följande kod:
<%
Dim objConn, objRS, eNumber, antal
eNumber = Replace(Request.Querystring("eNumber"), "'", "''")
antal = Replace(Request.Querystring("antal"), "'", "''")
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.ConnectionString = "DSN=IntranetSydostel"
objConn.Open
if eNumber <> "" and antal<>"" then
strSQL = "INSERT INTO tblCart (eNumber, quantity, userID) VALUES ('" & eNumber & "', " & antal & ", " & session("userId") & ")"
objConn.execute strSQL,,128
end if
response.write("<select name=meny>" & chr(10))
strSQL = "SELECT * FROM tblCart WHERE userId = " & Session("userId") & ""
Set objRS = objConn.Execute(strSQL)
Dim totSum, totProd
totSum = 0
totProd = 0
if objRS.eof then
response.write("<option value=''>Kundvagnen är tom</option>" & chr(10))
else
do until objRS.eof
response.write("<option value=''>" & objRS("eNumber") & "</option>" & chr(10))
'totSum = totSum - -cint(objRS("articlePrice"))
totProd = totProd - -1
objRS.MoveNext
loop
end if
response.write("</select>" & chr(10))
response.write("Antal Produkter: " & totProd & "<br />")
response.write("Total Summa: " & formatcurrency(totSum, 2) & "<br />")
objRS.Close
Set objRS = Nothing
objConn.Close
Set objConn = Nothing
%>
Jag får det när ingen användare är inloggad. Dvs session("userId") är tom.
Hur gör jag för att undvika detta??
Mvh
If-sats, min vän:
If session("userid") <> "" then
' sessionsvariabeln [i]userid[/i] har ett värde, gör saker och ting
End if
mvh
devotion skrev:
If session("userid") <> ""Vad betyder raden på svenska... :r
Om sessionsvariabeln "userid" inte är en tom sträng.
<> betyder något annat än det du sätter på andra sidan..
Session("userId") <> ""
betyder således att userId har något värde och inte är tomt.
mvh
Ok!
Då stämmer mina mattekunskaper "störrre än / mindre än"
Tack!
Vågade inte skriva det först... :)