[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 890
  • Last Modified:

"NAME REDEFINED" ERROR

I can't explain this behavior. I have always been able to Dim my variables ANYWHERE in the code including includes. However, the IIS environment I am currently working in shows a quirky error that I can't explain.

If I Dim variables on certain includes throughout the site I get the following error even after makinig sure there is NO WAY in the world the variable could be redefined. See error below:

----------------------------------------------------------------------

Microsoft VBScript compilation error '800a0411'

Name redefined

/inc/states.asp, line 5

Dim no_way_anyone_would_use_this_variable
----^

----------------------------------------------------------------------

Has this ever happened to anyone??? What is the cause??? The only work around is to Dim the variable on the page calling the include but this is unacceptable when working with global includes. It defeats the purpose of an include. Make your changes once.

HELP

0
HangTenDesign
Asked:
HangTenDesign
  • 5
  • 4
  • 3
  • +1
3 Solutions
 
Brandy VaughnCommented:
Name redefined means that you have initialized the same variable twice. If you have Dim i in your include file and Dim i in the page including that file, you'll get that error. You have to remove the Dim from one of those variables or use a different variable name.

Brandy
0
 
Brandy VaughnCommented:
oops declared the same variable twice...
0
 
HangTenDesignAuthor Commented:
If you read my question again, you'll see that there is no way THAT variable would be declared twice as I made it up (something utterly rediculous) and declared it there for the first time ever. I even checked to see if it was somehow in a loop but that is not the case. (Of course I know what the error means. I want to know why I am getting that error when I know FOR A FACT that that variable never existed before. Also did global search for variable. Only only one Dim exists.)
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
snavebelacCommented:
Are you definitely not including the same page twice for any reason?? - perhaps in a loop or If...Then / Select...Case...??

C
0
 
Brandy VaughnCommented:
Try removing the dim and see what happens...
0
 
snavebelacCommented:
Do you have that file included in the contents of another include anywhere ?

C
0
 
NaliniPCommented:
what are the files you are including? and where u defined this variable..i mean which include file.

If may be because of you defined that variable in 1 file and included that file in 2nd file. And finally this 2nd file is included in a 3rd file where the 1st file already included accidently some how. I am guessing this. not sure. check all the includes.
0
 
HangTenDesignAuthor Commented:
brandybateman, I removed the Dim and got the expected "Variable is undefined" cause I'm using Option Explicit.

snavebelac , I did a search on the include page and I'm only calling it once in one Select Case.
0
 
snavebelacCommented:
Can you post your code please... i dont know what else to suggest

C
0
 
HangTenDesignAuthor Commented:
I know, I've exhausted all possiblities myself that's why my question was "Has this ever happened to anyone???"

Here is the code of the include where I'm getting the error but I don't think it will help you:

-------------------------------------------------------------------------------------------

            <option value="">Select a State</option>
<!-- #include virtual="/inc/get_db_conn.asp" -->
<%
Dim bSkipSelect '--------------------------> error occurs here. I even changed this variable to "no_way_anyone_would_use_this_variable" and it still didn't work
If allMode Then
            'Should just display a list of states
        Set rsSov = dbConn.Execute("select * from state order by state_name")
        While Not rsSov.EOF
              stateCd = rsSov("state_cd")
              stateDesc = rsSov("state_name")
                    If stateCd = selectedState Then
      %>
        <option selected value="<%=stateCd%>"><%=stateDesc%></option>
      <%
                  Else
      %>
        <option value="<%=stateCd%>"><%=stateDesc%></option>
      <%
                  End If
              rsSov.moveNext
        Wend
Else
             'display states we operate in, then the rest
        Set rsSov = dbConn.Execute("select * from state where SOV_CD = 'Y'")
        While Not rsSov.EOF
              stateCd = rsSov("state_cd")
              stateDesc = rsSov("state_name")
                    If stateCd = selectedState Then
                        bSkipSelect = True
      %>
        <option selected value="<%=stateCd%>"><%=stateDesc%></option>
      <%
                  Else
      %>
        <option value="<%=stateCd%>"><%=stateDesc%></option>
      <%
                  End If
              rsSov.moveNext
        Wend
%>
        <option value="">---------</option>
<%
            'Now the rest
        'Set rsSov = dbConn.Execute("select * from state where SOV_CD = 'N' order by state_name")
        Set rsSov = dbConn.Execute("select * from state order by state_name")
        While Not rsSov.EOF
              stateCd = rsSov("state_cd")
              stateDesc = rsSov("state_name")
                    If stateCd = selectedState And Not bSkipSelect = True Then
      %>
        <option selected value="<%=stateCd%>"><%=stateDesc%></option>
      <%
                  Else
      %>
        <option value="<%=stateCd%>"><%=stateDesc%></option>
      <%
                  End If
              rsSov.moveNext
        Wend
             
End If
%>
-----------------------------------------------------------------------------------------

0
 
snavebelacCommented:
Can you also post the code o fthe page where this is included please.  As you say i am not sure it will help but it may be beneficial to have some fresh eyes looking over it all.

C
0
 
HangTenDesignAuthor Commented:
I found another global include nested deep and outside of my own site where states.asp was being compiled twice. I will split the points. I would not have gotten this without talking it out with you guys. Thanks!!!!!!!!
0
 
snavebelacCommented:
Thanks for the points and glad it worked out for you

C
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 5
  • 4
  • 3
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now