943,712 Members | Top Members by Rank

Ad:
Feb 12th, 2009
0

VB Syntax error appears in one page but not the other?

Expand Post »
So Ive been working really hard to get a working ASP captcha to incorporate into my form (note, classic ASP not .net).

I FINALLY got it working in a test area, the form looks like this:

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1.  
  2.  
  3. <form action="<%=Request.ServerVariables("SCRIPT_NAME")%>" method="post">
  4. <table border="0" width="570" align="center" cellpadding="1" cellspacing="0">
  5. <tr>
  6. <td align="right" valign="center"><%=font4%><font color="#ff0000">*&nbsp;</font>First Name:&nbsp;</td>
  7. <td align="left" valign="top"><input name="first" size="25" maxlength="50" tabindex="1"></td>
  8. </tr>
  9. <tr>
  10. <td align="right"><%=font4%><font color="#ff0000">*&nbsp;</font>Last Name:&nbsp;</font></td>
  11. <td align="left"><input name="last" size="25" maxlength="50" tabindex="2"></td>
  12. </tr>
  13. <tr>
  14. <td align="right"><%=font4%>Company Name:&nbsp;</font></td>
  15. <td align="left"><input name="company" size="25" maxlength="100" tabindex="3"></td>
  16. </tr>
  17. <tr>
  18. <td align="right"><%=font4%><font color="#ff0000">*&nbsp;</font>E-Mail&nbsp;Address:&nbsp;</font></td>
  19. <td align="left"><input name="email" size="25" maxlength="100" tabindex="4"></td>
  20. </tr>
  21. <tr>
  22. <td align="right"><%=font4%> Phone:&nbsp;</font></td>
  23. <td align="left"><input name="phone" size="25" maxlength="20" tabindex="5"></td>
  24. </tr>
  25.  
  26. <tr>
  27. <td align="right"><%=font4%> Part# 1:&nbsp;</font></td>
  28. <td align="left"><input name="partno1" size="25" maxlength="50" tabindex="6"></td>
  29. </tr>
  30. <tr>
  31. <td align="right"><%=font4%> Part# 2:&nbsp;</font></td>
  32. <td align="left"><input name="partno2" size="25" maxlength="50" tabindex="7"></td>
  33. </tr>
  34. <tr>
  35. <td align="right"><%=font4%> Part# 3:&nbsp;</font></td>
  36. <td align="left"><input name="partno3" size="25" maxlength="50" tabindex="8"></td>
  37. </tr>
  38. <tr>
  39. <td align="right"><%=font4%> Part# 4:&nbsp;</font></td>
  40. <td align="left"><input name="partno4" size="25" maxlength="50" tabindex="9"></td>
  41. </tr>
  42.  
  43. <tr>
  44. <td align="right" valign="top"><%=font4%><font color="#ff0000">*&nbsp;</font>Comments:&nbsp;</td>
  45. <td align="left"><textarea name="message" rows="8" wrap="virtual" cols="20" tabindex="10"></textarea></td>
  46. </tr>
  47. <tr>
  48. <td align="right" valign="top">&nbsp;</td>
  49. <td align="left">
  50.  
  51. <%
  52. 'Specify your captcha length here
  53. captchaLength = 5
  54.  
  55. Function captcha(captchaLength)
  56. if captchaLength > 15 then captchaLength = 15
  57. HighestValue = left(100000000000000,captchaLength)
  58. lowestValue = left(999999999999999,captchaLength)
  59. Randomize
  60. intHighestNumber = Int((HighestValue - LowestValue + 1) * Rnd) + LowestValue
  61. session("captcha") = Int(intHighestNumber)
  62. x = 1
  63. response.write vbcrlf & "<table width = ''>" & vbcrlf & vbtab & "<tr>" & vbcrlf
  64. while x <= captchaLength
  65. response.write vbtab & vbtab & "<td align = 'center'><img src = 'captcha.asp?captchaID=" & x & "' ></td>" & vbcrlf
  66. x = x + 1
  67. wend
  68. response.write vbtab & "</tr>" & vbcrlf & "</table>" & vbcrlf
  69. End Function
  70. %>
  71.  
  72. <%
  73. if request("action") = "captcha" then
  74. if cstr(request("captcha")) = cstr(session("captcha")) then
  75. response.write "Correct!"
  76. else
  77. response.write "Sorry, no match."
  78. end if
  79. end if
  80. %>
  81.  
  82. Enter Code: <input name="captcha"> <BR />
  83. <input type="submit" name="submit" src="images/b_submit.gif" border="0" tabindex="13" id="image1" value="Submit"></td>
  84. </tr>
  85. </table>
  86. </form>

it works great, but as soon as I move it over to the page I need it to and incorporate that form into it, I get a VB error. The error says:

Microsoft VBScript compilation error '800a03ea'

Syntax error

/RoHSCompliant2.asp, line 174

Function captcha(captchaLength)
^


so i know where the error is but not how to remedy it. why would it be doing this? what code in the rest of the page could pull such an error?

THANKS!
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Ortal is offline Offline
15 posts
since Apr 2007
Apr 22nd, 2009
0

Re: VB Syntax error appears in one page but not the other?

We had a similar error and it transpired our function decleration was inside a loop.

It wasn't obvious to us at first, as the function dec was inside an include, and the loop was in the parent page.

Hope this helps.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
navertech is offline Offline
1 posts
since Apr 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Visual Basic 4 / 5 / 6 Forum Timeline: about registry key . . .
Next Thread in Visual Basic 4 / 5 / 6 Forum Timeline: how to resize the coordinates of the picture





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC