Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

ASP.NET Forum


You are currently viewing our ASP.NET Forum as a guest. Please register to participate.
Login



Reply
formmail.asp problem - Subscript out of range
Old 07-12-2007, 12:11 AM formmail.asp problem - Subscript out of range
Novice Talker

Posts: 8
Trades: 0
  • Microsoft VBScript runtime error '800a0009'Subscript out of range: '[number: 2]'
    /formmail.asp, line 96
Here is the problem code (line 96 is in red):

'----------------------------------------------------------------------------------------------------
'verify the referer
'----------------------------------------------------------------------------------------------------
referer = request.ServerVariables("HTTP_REFERER")
referer = split(referer,"/")
url_verified = "no"
for icounter = Lbound(url) to Ubound(url) '
if referer(2) = url(icounter) then
url_verified = "yes"
end if
next
if not url_verified = "yes" then
response.write("The url specified is invalid!")
response.End
end if


CAN ANYONE PLEASE HELP??!!!!

Last edited by unclechris; 07-12-2007 at 12:14 AM..
unclechris is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 07-12-2007, 09:45 AM Re: formmail.asp problem - Subscript out of range
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,519
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
1 - referer is probably empty or not an array
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 07-12-2007, 10:23 AM Re: formmail.asp problem - Subscript out of range
Novice Talker

Posts: 8
Trades: 0
OK - here's the deal...

formmail.asp is a free script by sortedsites.com, written as an asp alternative to the popular CGI script by Matt Wright - I'm pretty sure it is used by literally millions of users. Yet, I cannot find this error reported anywhere else.

Also, this error was reported to me by a client who got it after taking the time to fill out my form. I cannot replicate the error and I've never had anyone report it before either.

So, I guess my questions are:

1.) How could the referrer be empty?
2.) What could I do to correct this issue?

btw - here where the array is defined:

'Referrer's Array is defined here. Enter the valid domains which may use this script.
url = Array("www.your-domain.com","your-domain.com")'Set which urls that will be accepted. http://xxxxx/
unclechris is offline
Reply With Quote
View Public Profile
 
Old 07-12-2007, 10:50 AM Re: formmail.asp problem - Subscript out of range
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,519
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Quote:
How could the referrer be empty?
Very easily;

it is not a required field in the HTTP protocol and it is only filled when a link is "clicked". So, there is no referer from "bookmarks" or "typeins" and many "Internet Security", Privacy and Anti-virus / Anti spyware programs remove it from the browser.

You should not rely on it being there and check that it has a value before you try to use it.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 07-12-2007, 01:17 PM Re: formmail.asp problem - Subscript out of range
ADAM Web Design's Avatar
Canadastaninianite

Posts: 5,938
Name: Adam for web page design, not program
Location: Toronto, Ontario, Canada
Trades: 0
Quote:
formmail.asp is a free script by sortedsites.com, written as an asp alternative to the popular CGI script by Matt Wright - I'm pretty sure it is used by literally millions of users. Yet, I cannot find this error reported anywhere else.
That's because most ASP coders don't know bugger all about coding and errors like this usually go unreported and/or unresolved as a result. It also probably isn't used as often as you might think.

if you want the fix, add these two lines.

Line 1:
Code:
referer = request.ServerVariables("HTTP_REFERER") 
if referer <> "" then
Line 2:

Code:
if not url_verified = "yes" then 
response.write("The url specified is invalid!")
response.End
end if
end if ' this closes the first if condition that I created.
As Chris Hirst pointed out, you're not going to get a referral from type-in traffic, search engine spiders who revisit the page to try and reindex it without necessarily hitting another link first, pro-privacy programs, and some proxy servers.

There's a much more important lesson here that you should learn, unclechris, and you may not learn it the first time: 99.999% of ASP prewritten scripts suck and are faulty. They don't take into account all situations and are one-size-fits-a-small-market-so-it's-assumed-that-one-size-fits-all-solutions. The best thing you can do is to learn how to code a script like this yourself, and not rely on other people to come up with code samples for you.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
(my blog)


Please login or register to view this content. Registration is FREE
(with proof)
ADAM Web Design is offline
Reply With Quote
View Public Profile Visit ADAM Web Design's homepage!
 
Old 07-12-2007, 01:26 PM Re: formmail.asp problem - Subscript out of range
Novice Talker

Posts: 8
Trades: 0
Quote:
Originally Posted by ADAM Web Design View Post

That's because most ASP coders don't know bugger all about coding and errors like this usually go unreported and/or unresolved as a result.
well, maybe we'll all help a few souls out in the future when this page gets googled :-)

Thanks for the input and the fix Chris/Adam. Truely appreciated.


Quote:
Originally Posted by ADAM Web Design View Post
There's a much more important lesson here that you should learn, unclechris, and you may not learn it the first time: 99.999% of ASP prewritten scripts suck and are faulty. They don't take into account all situations and are one-size-fits-a-small-market-so-it's-assumed-that-one-size-fits-all-solutions. The best thing you can do is to learn how to code a script like this yourself, and not rely on other people to come up with code samples for you.
I'm trying, and will continue to! Thanks again.
unclechris is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to formmail.asp problem - Subscript out of range
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.23327 seconds with 12 queries