Link to home
Start Free TrialLog in
Avatar of Sevron
Sevron

asked on

Classic ASP If statement not working

if session("pkContactID")<>request("pkContactID") or session("userlevel")<>"4" then
%>
You do not have sufficient permissions to edit this account!
<%
else

end if

Open in new window


We have a problem with the conditional statement above, it is not going into the else part of the statement.
I have checked the values for the session("pkContactID") and request("pkContactID") and they are the same but yet it sill does not go into the else.
When I dont have the or clause and just check session("userlevel") it goes into the else but as soon as I include the additional or condition it fails.
Am I missing some logic or is ASP being quirky?

If anyone can help that would be awesome.

Thanks.
Avatar of gladxml
gladxml

try this might help

if (Trim(session("pkContactID"))<>Trim((request("pkContactID")) or session("userlevel")<>"4") then
%>
You do not have sufficient permissions to edit this account!
<%
else

end if
Avatar of James Williams
<%If Session("pkContactID") ..........................................then %>
You do not have sufficient permissions to edit this account!
<%Else%>
 WHAT ELSE
<%End If%>

Open in new window


sElvol
Avatar of Sevron

ASKER

Hi thanks for the reply.
We tried that also however it did not help.
it might be you are trying to compare string and numbers

try this

Cstr(session("pkContactID"))<>Cstr((request("pkContactID"))
ASKER CERTIFIED SOLUTION
Avatar of gladxml
gladxml

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Sevron

ASKER

Thanks, I managed to fix it with the following code.
By Using Trim and Cstr and also changing the or to an and.

if session("userlevel")<>"4" and Trim(CStr(session("pkContactID")))<>Trim(CStr(request("pkContactID"))) then
%>
You do not have sufficient permissions to edit this account!
<%
else

end if

Open in new window