Solved

Classic ASP If statement not working

Posted on 2014-11-07
6
357 Views
Last Modified: 2014-11-07
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.
0
Comment
Question by:Sevron
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 15

Expert Comment

by:gladxml
ID: 40427886
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
0
 
LVL 17

Expert Comment

by:selvol
ID: 40427890
<%If Session("pkContactID") ..........................................then %>
You do not have sufficient permissions to edit this account!
<%Else%>
 WHAT ELSE
<%End If%>

Open in new window


sElvol
0
 

Author Comment

by:Sevron
ID: 40427892
Hi thanks for the reply.
We tried that also however it did not help.
0
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 
LVL 15

Expert Comment

by:gladxml
ID: 40427896
it might be you are trying to compare string and numbers

try this

Cstr(session("pkContactID"))<>Cstr((request("pkContactID"))
0
 
LVL 15

Accepted Solution

by:
gladxml earned 500 total points
ID: 40427900
you can try the code below

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

end if
%>

HTH
0
 

Author Closing Comment

by:Sevron
ID: 40427938
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

0

Featured Post

Enroll in June's Course of the Month

June’s Course of the Month is now available! Experts Exchange’s Premium Members, Team Accounts, and Qualified Experts have access to a complimentary course each month as part of their membership—an extra way to sharpen your skills and increase training.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

695 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question