Go Back   PCMech Forums > Help & Discussion > Web Design / Development

Need Some Help? Type Your Keywords Here:

Reply
 
LinkBack Thread Tools Search this Thread Rating: Thread Rating: 8 votes, 2.00 average. Display Modes
Old 02-20-2002, 06:13 PM   #1
Member (8 bit)
 
Join Date: Jan 2001
Location: Christiansburg, Virginia
Posts: 246
Send a message via AIM to DukeDiablo
Question VBScript Question

Dear Forum-

I am currently putting together a small customer/order system for a school project using VBScript in ASP pages.

This is my problem...

Internet Explorer tells me...

"Microsoft VBScript compilation error '800a040e'

'loop' without 'do'

/login.asp, line 88

Loop
^

This is a snippet of my code which seems to contain the problem...

Do Until PHFRecordset.EOF

CurrentJobType = PHFRecordset("JobType")
CurrentPassword =PHFRecordset("Password")
CurrentName = PHFRecordset("UserName")

If UserID = CurrentName AND Password = CurrentPassword Then

If CurrentJobType = 1 OR CurrentJobType = 2 Then

Response.Redirect "PHF_Index.asp?UserID=&=UserID&UserType=Manager"

ElseIf CurrentJobType = 3 OR CurrentJobType = 4 Then %>

Response.Redirect "PHF_Index.asp?UserID=&=UserID&UserType=Sales"

End If

PHFRecordset.MoveNext

Loop

Else...a bunch of other code...

I think my problem is that I have a nested If statement inside of the Do Loop, but I'm pretty sure that is a legal programming operation. I did take out my If statements, and just put in some trivial program that printed out a series of numbers using the Loop, and I encountered zero errors.

I guess I would just like to know if it's possible to perform the operation I'm trying to do.

Sorry for all the code mess, but I would greatly appreciate any help/advice on this issue.
DukeDiablo is offline   Reply With Quote
Old 02-21-2002, 02:31 AM   #2
Member (10 bit)
 
Join Date: Jan 2001
Location: Birmingham, UK.
Posts: 553
Send a message via Yahoo to dj4uk
Few problems with the code you posted:
Quote:
Do Until PHFRecordset.EOF

CurrentJobType = PHFRecordset("JobType")
CurrentPassword =PHFRecordset("Password")
CurrentName = PHFRecordset("UserName")

If UserID = CurrentName AND Password = CurrentPassword Then

If CurrentJobType = 1 OR CurrentJobType = 2 Then

Response.Redirect "PHF_Index.asp?UserID=&=UserID&UserType=Manager"

ElseIf CurrentJobType = 3 OR CurrentJobType = 4 Then %>

Response.Redirect "PHF_Index.asp?UserID=&=UserID&UserType=Sales"

End If

PHFRecordset.MoveNext

Loop
Firstly there is a %> which isn't needed.

Also one of the if statements isn't ended.
dj4uk is offline   Reply With Quote
Old 02-21-2002, 06:04 AM   #3
Member (8 bit)
 
Join Date: Jan 2001
Location: Christiansburg, Virginia
Posts: 246
Send a message via AIM to DukeDiablo
Thanks for checking...

The VBScript bracket was just something I forgot to omit when I posted...and the If statement is terminated with an "End If" but showing that would require way too much code for a post, so I left it out.

Thanks for looking into it though.
DukeDiablo is offline   Reply With Quote
Old 02-21-2002, 06:59 AM   #4
Member (10 bit)
 
Join Date: Jan 2001
Location: Birmingham, UK.
Posts: 553
Send a message via Yahoo to dj4uk
Why not attach a text file with the full code - can't really find a problem if we can't see all the code.
dj4uk is offline   Reply With Quote
Old 02-21-2002, 07:09 AM   #5
Member (8 bit)
 
Join Date: Jan 2001
Location: Christiansburg, Virginia
Posts: 246
Send a message via AIM to DukeDiablo
Good idea, sorry I wasn't very helpful before...
Attached Files
File Type: txt login.txt (6.5 KB, 69 views)
DukeDiablo is offline   Reply With Quote
Old 02-21-2002, 07:24 AM   #6
Member (10 bit)
 
Join Date: Jan 2001
Location: Birmingham, UK.
Posts: 553
Send a message via Yahoo to dj4uk
Your problem is where I mentioned.
PHP Code:
<% Do Until PHFRecordset.EOF %>
<% 
CurrentJobType PHFRecordset("JobType")
CurrentPassword =PHFRecordset("Password")
CurrentName PHFRecordset("UserName") %>
<% If 
UserID CurrentName AND Password CurrentPassword Then %> 
<% If 
CurrentJobType OR CurrentJobType 2 Then %>
<% 
Response.Redirect "PHF_Index.asp?UserID=&=UserID&UserType=Manager" %>
<% ElseIf 
CurrentJobType OR CurrentJobType 4 Then %>
<% 
Response.Redirect "PHF_Index.asp?UserID=&=UserID&UserType=Sales" %>
<% 
End If %>        
<% 
PHFRecordset.MoveNext %>
<% 
Loop %> 
You have opened two if statements in the loop and only closed one. Basically if this loop is used more than once (i.e. the End of the Recordset is not reached after one record) then more and more if statements are started and not ended.

This means all statements used within a loop must be ended before the end of the loop.

I'll try to have a look through the code in more detail later for suggestions.

Last edited by dj4uk; 02-21-2002 at 07:27 AM.
dj4uk is offline   Reply With Quote
Old 02-21-2002, 07:27 AM   #7
Member (8 bit)
 
Join Date: Jan 2001
Location: Christiansburg, Virginia
Posts: 246
Send a message via AIM to DukeDiablo
Thanks so much DJ-

Sorry to have bothered you with my problem, and please don't take up too much of your time on it. I'll try to look through it myself now that I know what type of problem I have.
DukeDiablo is offline   Reply With Quote
Reply

Bookmarks

Still Need Help? Type Your Keywords Here:


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 07:51 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
SEO by vBSEO 3.6.0 PL2