Link to home
Create AccountLog in
Avatar of Bob Schneider
Bob SchneiderFlag for United States of America

asked on

Mysterious Classic ASP Error

I am getting this error when I load a page this page: http://www.gtraxc.com/pages/results/results.asp

LineNumber 2 
ErrorCode 800a03f6 

Description Expected 'End' 

Open in new window


The problem is that there seems to be nothing wrong anywhere near Line 2.  These are the first three lines...:
<%@ Language=VBScript %>
<%
Option Explicit

Open in new window


I can't find any unterminated "If" statements.  Any help would be much appreciated.
Avatar of Scott Fell
Scott Fell
Flag of United States of America image

Bob, I think you have an issue with your If/Then logic.


In a case like this, one way I troubleshoot is to make sure the code is nested.  Go through the code line by line and make sure the nesting is correct. This does not help with the code, just helps you identify the issue.

If X = 3 then 
response.write("something")
if
end if

Open in new window


If X = 3 then
     response.write("something")

     if
end if

Open in new window


Looking above, it is easy to spot there is a if without a end if.

If the code is very long, you can start pulling things out and putting them back one by one. But the issue is an unmatched if/end
SOLUTION
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of Bob Schneider

ASKER

Hi folks.  I try hard to have readable code, including indenting, and I have been unable to find the issue.  The interesting thing is I put a Response.End right after my variable declarations (ie: after Line 2) and it still threw the error, when it really should have rendered a blank page.  Does that mean that it could be an include?  I do use includes but I use most of the same ones on several pages and this is the only one causing the error.  I assume the server processes the server side script first syntax and then other code?

BTW, here are the first two lines again:
<%@ Language=VBScript %>
<%

Open in new window


Thanks for your help.
ASKER CERTIFIED SOLUTION
Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
are you serving your asp pages via IIS?

what if you trying putting the quotes around?
<%@ Language="VBScript" %>

Open in new window

I'm using iis8 and this syntax works on all pages on multiple sites so I don't think that's the problem.  I tend to believe I am missing a simple error but what I don't know why it is rendering so early in the page...hence time to look at both of your suggestions re: includes...but, again, they are includes that I use on other pages as well will no issues.  I will keep looking...  Thanks!
Found it:

<End If%>  

(notice the missing "%").  

This was near the very bottom of the html.  :(  Thanks for your help!
Classic ASP is not the easiest to find errors.   That is why when I am really stuck, I just start rewriting the code in a new file line by line making sure to indent code and make it look pretty. That's how I find errors like this.  If the code is large, take small chunks at a time.
I actually did kind of the opposite.  I started removing blocks of code until it didn't throw an error...same result basically.  I also sometimes step through the code with the Response.End technique that I shared but, as we found out here, that doesn't always work.  Thanks again!!!!