Solved

Classic ASP If statement not working

Posted on 2014-11-07
6
300 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
  • 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

760 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now