Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_web_howto thread: Help please...


Message #1 by "propellerhead" <propellerhead@b...> on Wed, 2 Oct 2002 08:49:04 +1000
Hi,
 
tried this one on over at beginning asp to no avail. Its kinda urgent so
that's why i'm trying here.
 
thanks in advance 
 
g
 
good morning all, 

i am currently working on a project that has me using asp for the first
time. i am trying to generate a search that takes various user input and
builds a query. one of the things the user can input is some keywords
and this is where i am having some problems, the code is below:

If Request.form("keyword") <> "" Then 
  Dim searchwords
  tempinput=Request.form("keyword")
  searchwords=split(tempinput," ")
  maxcounter=ubound(searchwords)
  whereclause=" and keywords like '%" & searchwords(0) & "%'"
  FOR counter=1 TO maxcounter
      thissearchword=searchwords(counter)
      whereclause=whereclause & " OR keywords like '%" & thissearchword
& "%'"
  NEXT
strQuery = strQuery + whereclause
End If

the problem i am having is that i would like to put an initial value
into the keyword textarea on the page, eg. enter keywords however when i
do this i get the following error :

Error Type:
Microsoft VBScript runtime (0x800A0009)
Subscript out of range: '[number: 0]'

Now my understanding is that if i used: "If Request.form("keyword") <>
"enter keywords" Then" that part of the script would not be entered when
the initial value had not been changed from enter keywords.

if anyone can shed some light on what is probably a very simple problem,
i would be forever in your debt. 

many thanks in advance 

g


Message #2 by "Venkat" <yalamanchilivenkat@y...> on Wed, 2 Oct 2002 00:56:06
did you try putting in the for statement
FOR counter=1 TO (maxcounter-1 )
instead of
 FOR counter=1 TO maxcounter

sorry iam not pretty sure if this is the mistake,,normally the server 
gives the line number also where this is happening ,,so can you be precise 
what the line number is i.e which line
Thank you
Apply Thought


> Hi,
 
tried this one on over at beginning asp to no avail. Its kinda urgent so
that's why i'm trying here.
 
thanks in advance 
 
g
 
good morning all, 

i am currently working on a project that has me using asp for the first
time. i am trying to generate a search that takes various user input and
builds a query. one of the things the user can input is some keywords
and this is where i am having some problems, the code is below:

If Request.form("keyword") <> "" Then 
  Dim searchwords
  tempinput=Request.form("keyword")
  searchwords=split(tempinput," ")
  maxcounter=ubound(searchwords)
  whereclause=" and keywords like '%" & searchwords(0) & "%'"
  FOR counter=1 TO maxcounter
      thissearchword=searchwords(counter)
      whereclause=whereclause & " OR keywords like '%" & thissearchword
& "%'"
  NEXT
strQuery = strQuery + whereclause
End If

the problem i am having is that i would like to put an initial value
into the keyword textarea on the page, eg. enter keywords however when i
do this i get the following error :

Error Type:
Microsoft VBScript runtime (0x800A0009)
Subscript out of range: '[number: 0]'

Now my understanding is that if i used: "If Request.form("keyword") <>
"enter keywords" Then" that part of the script would not be entered when
the initial value had not been changed from enter keywords.

if anyone can shed some light on what is probably a very simple problem,
i would be forever in your debt. 

many thanks in advance 

g


Message #3 by propellerhead@b... on Wed, 2 Oct 2002 03:20:03
Thanks,

yes i was given a line number that referred to the following line:
whereclause=" and keywords like '%" & searchwords(0) & "%'"

thanks again

g

> did you try putting in the for statement
F> OR counter=1 TO (maxcounter-1 )
i> nstead of
 > FOR counter=1 TO maxcounter

> sorry iam not pretty sure if this is the mistake,,normally the server 
g> ives the line number also where this is happening ,,so can you be 
precise 
w> hat the line number is i.e which line
T> hank you
A> pply Thought

> 
>>  Hi,
 > 
t> ried this one on over at beginning asp to no avail. Its kinda urgent so
t> hat's why i'm trying here.
 > 
t> hanks in advance 
 > 
g> 
 > 
g> ood morning all, 

> i am currently working on a project that has me using asp for the first
t> ime. i am trying to generate a search that takes various user input and
b> uilds a query. one of the things the user can input is some keywords
a> nd this is where i am having some problems, the code is below:

> If Request.form("keyword") <> "" Then 
 >  Dim searchwords
 >  tempinput=Request.form("keyword")
 >  searchwords=split(tempinput," ")
 >  maxcounter=ubound(searchwords)
 >  whereclause=" and keywords like '%" & searchwords(0) & "%'"
 >  FOR counter=1 TO maxcounter
 >      thissearchword=searchwords(counter)
 >      whereclause=whereclause & " OR keywords like '%" & thissearchword
&>  "%'"
 >  NEXT
s> trQuery = strQuery + whereclause
E> nd If

> the problem i am having is that i would like to put an initial value
i> nto the keyword textarea on the page, eg. enter keywords however when i
d> o this i get the following error :

> Error Type:
M> icrosoft VBScript runtime (0x800A0009)
S> ubscript out of range: '[number: 0]'

> Now my understanding is that if i used: "If Request.form("keyword") <>
"> enter keywords" Then" that part of the script would not be entered when
t> he initial value had not been changed from enter keywords.

> if anyone can shed some light on what is probably a very simple problem,
i>  would be forever in your debt. 

> many thanks in advance 

> g

> 
Message #4 by "Ken Schaefer" <ken@a...> on Wed, 2 Oct 2002 12:22:09 +1000
You are doing:

From counter = 1 to maxcount

What if maxcount is less that 1? Remember, the LBound() of a VBScript array
is always 0, so you should check to see if maxcount is > 0 before doing the
From...Loop

Cheers
Ken

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: "propellerhead" <propellerhead@b...>
To: "ASP Web HowTo" <asp_web_howto@p...>
Sent: Wednesday, October 02, 2002 8:49 AM
Subject: [asp_web_howto] Help please...


: Hi,
:
: tried this one on over at beginning asp to no avail. Its kinda urgent so
: that's why i'm trying here.
:
: thanks in advance
:
: g
:
: good morning all,
:
: i am currently working on a project that has me using asp for the first
: time. i am trying to generate a search that takes various user input and
: builds a query. one of the things the user can input is some keywords
: and this is where i am having some problems, the code is below:
:
: If Request.form("keyword") <> "" Then
:   Dim searchwords
:   tempinput=Request.form("keyword")
:   searchwords=split(tempinput," ")
:   maxcounter=ubound(searchwords)
:   whereclause=" and keywords like '%" & searchwords(0) & "%'"
:   FOR counter=1 TO maxcounter
:       thissearchword=searchwords(counter)
:       whereclause=whereclause & " OR keywords like '%" & thissearchword
: & "%'"
:   NEXT
: strQuery = strQuery + whereclause
: End If
:
: the problem i am having is that i would like to put an initial value
: into the keyword textarea on the page, eg. enter keywords however when i
: do this i get the following error :
:
: Error Type:
: Microsoft VBScript runtime (0x800A0009)
: Subscript out of range: '[number: 0]'
:
: Now my understanding is that if i used: "If Request.form("keyword") <>
: "enter keywords" Then" that part of the script would not be entered when
: the initial value had not been changed from enter keywords.
:
: if anyone can shed some light on what is probably a very simple problem,
: i would be forever in your debt.
:
: many thanks in advance
:
: g
:
:
:
:
: ---
:
: Improve your web design skills with these new books from Glasshaus.
:
: Usable Web Menus
: http://www.amazon.com/exec/obidos/ASIN/1904151027/ref=nosim/theprogramme
: r-20
: Constructing Accessible Web Sites
: http://www.amazon.com/exec/obidos/ASIN/1904151000/ref=nosim/theprogramme
: r-20
: Practical JavaScript for the Usable Web
: http://www.amazon.com/exec/obidos/ASIN/1904151051/ref=nosim/theprogramme
: r-20

Message #5 by propellerhead@b... on Fri, 4 Oct 2002 01:37:13
Thanks, changing to If maxcounter >= 0 Then... appears to have worked.

one of my original questions remains though. if i have 

If Request.form("keyword" <> "Enter keywords" Then...

and keyword does infact = Enter keywords, shouldn't the statement be 
skipped over?

apologies for my ignorance...

g

> You are doing:

From counter = 1 to maxcount

What if maxcount is less that 1? Remember, the LBound() of a VBScript 
array
is always 0, so you should check to see if maxcount is > 0 before doing 
the
From...Loop

Cheers
Ken

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: "propellerhead" <propellerhead@b...>
To: "ASP Web HowTo" <asp_web_howto@p...>
Sent: Wednesday, October 02, 2002 8:49 AM
Subject: [asp_web_howto] Help please...


: Hi,
:
: tried this one on over at beginning asp to no avail. Its kinda urgent so
: that's why i'm trying here.
:
: thanks in advance
:
: g
:
: good morning all,
:
: i am currently working on a project that has me using asp for the first
: time. i am trying to generate a search that takes various user input and
: builds a query. one of the things the user can input is some keywords
: and this is where i am having some problems, the code is below:
:
: If Request.form("keyword") <> "" Then
:   Dim searchwords
:   tempinput=Request.form("keyword")
:   searchwords=split(tempinput," ")
:   maxcounter=ubound(searchwords)
:   whereclause=" and keywords like '%" & searchwords(0) & "%'"
:   FOR counter=1 TO maxcounter
:       thissearchword=searchwords(counter)
:       whereclause=whereclause & " OR keywords like '%" & thissearchword
: & "%'"
:   NEXT
: strQuery = strQuery + whereclause
: End If
:
: the problem i am having is that i would like to put an initial value
: into the keyword textarea on the page, eg. enter keywords however when i
: do this i get the following error :
:
: Error Type:
: Microsoft VBScript runtime (0x800A0009)
: Subscript out of range: '[number: 0]'
:
: Now my understanding is that if i used: "If Request.form("keyword") <>
: "enter keywords" Then" that part of the script would not be entered when
: the initial value had not been changed from enter keywords.
:
: if anyone can shed some light on what is probably a very simple problem,
: i would be forever in your debt.
:
: many thanks in advance
:
: g
:
:
:
:
: ---
:
: Improve your web design skills with these new books from Glasshaus.
:
: Usable Web Menus
: http://www.amazon.com/exec/obidos/ASIN/1904151027/ref=nosim/theprogramme
: r-20
: Constructing Accessible Web Sites
: http://www.amazon.com/exec/obidos/ASIN/1904151000/ref=nosim/theprogramme
: r-20
: Practical JavaScript for the Usable Web
: http://www.amazon.com/exec/obidos/ASIN/1904151051/ref=nosim/theprogramme
: r-20

Message #6 by "Ken Schaefer" <ken@a...> on Fri, 4 Oct 2002 11:48:08 +1000
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: <propellerhead@b...>
Subject: [asp_web_howto] Re: Help please...


: Thanks, changing to If maxcounter >= 0 Then... appears to have worked.
:
: one of my original questions remains though. if i have
:
: If Request.form("keyword" <> "Enter keywords" Then...
:
: and keyword does infact = Enter keywords, shouldn't the statement be
: skipped over?

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
According to the code you posted you are doing:

: If Request.form("keyword") <> "" Then

which doesn't seem to be what you're saying you want to do above. :-)

Cheers
Ken


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Old Thread Follows
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

: > You are doing:
:
: From counter = 1 to maxcount
:
: What if maxcount is less that 1? Remember, the LBound() of a VBScript
: array
: is always 0, so you should check to see if maxcount is > 0 before doing
: the
: From...Loop
:
: Cheers
: Ken
:
: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
: From: "propellerhead" <propellerhead@b...>
: To: "ASP Web HowTo" <asp_web_howto@p...>
: Sent: Wednesday, October 02, 2002 8:49 AM
: Subject: [asp_web_howto] Help please...
:
:
: : Hi,
: :
: : tried this one on over at beginning asp to no avail. Its kinda urgent so
: : that's why i'm trying here.
: :
: : thanks in advance
: :
: : g
: :
: : good morning all,
: :
: : i am currently working on a project that has me using asp for the first
: : time. i am trying to generate a search that takes various user input and
: : builds a query. one of the things the user can input is some keywords
: : and this is where i am having some problems, the code is below:
: :
: : If Request.form("keyword") <> "" Then
: :   Dim searchwords
: :   tempinput=Request.form("keyword")
: :   searchwords=split(tempinput," ")
: :   maxcounter=ubound(searchwords)
: :   whereclause=" and keywords like '%" & searchwords(0) & "%'"
: :   FOR counter=1 TO maxcounter
: :       thissearchword=searchwords(counter)
: :       whereclause=whereclause & " OR keywords like '%" & thissearchword
: : & "%'"
: :   NEXT
: : strQuery = strQuery + whereclause
: : End If
: :
: : the problem i am having is that i would like to put an initial value
: : into the keyword textarea on the page, eg. enter keywords however when i
: : do this i get the following error :
: :
: : Error Type:
: : Microsoft VBScript runtime (0x800A0009)
: : Subscript out of range: '[number: 0]'
: :
: : Now my understanding is that if i used: "If Request.form("keyword") <>
: : "enter keywords" Then" that part of the script would not be entered when
: : the initial value had not been changed from enter keywords.
: :
: : if anyone can shed some light on what is probably a very simple problem,
: : i would be forever in your debt.
: :
: : many thanks in advance
: :
: : g


Message #7 by propellerhead@b... on Fri, 4 Oct 2002 03:32:47
Ken you are correct, i didn't post my message very well...

when i use If request.form("keyword")<> "" then...

everything worked ok, i wasn't getting the out of range error but as soon 
as i changed it to If request.form("keyword")<> "Enter keywords" then...
i would get the error...

so... i have as my initial value in the form element "keyword" "Enter 
keywords" i am wondering why the code within the If statement is being 
processed as the condition should be false i.e. request.form("keyword") 
does infact equal Enter keywords...

eternally confused

g



> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: <propellerhead@b...>
Subject: [asp_web_howto] Re: Help please...


: Thanks, changing to If maxcounter >= 0 Then... appears to have worked.
:
: one of my original questions remains though. if i have
:
: If Request.form("keyword" <> "Enter keywords" Then...
:
: and keyword does infact = Enter keywords, shouldn't the statement be
: skipped over?

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
According to the code you posted you are doing:

: If Request.form("keyword") <> "" Then

which doesn't seem to be what you're saying you want to do above. :-)

Cheers
Ken


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Old Thread Follows
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

: > You are doing:
:
: From counter = 1 to maxcount
:
: What if maxcount is less that 1? Remember, the LBound() of a VBScript
: array
: is always 0, so you should check to see if maxcount is > 0 before doing
: the
: From...Loop
:
: Cheers
: Ken
:
: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
: From: "propellerhead" <propellerhead@b...>
: To: "ASP Web HowTo" <asp_web_howto@p...>
: Sent: Wednesday, October 02, 2002 8:49 AM
: Subject: [asp_web_howto] Help please...
:
:
: : Hi,
: :
: : tried this one on over at beginning asp to no avail. Its kinda urgent 
so
: : that's why i'm trying here.
: :
: : thanks in advance
: :
: : g
: :
: : good morning all,
: :
: : i am currently working on a project that has me using asp for the 
first
: : time. i am trying to generate a search that takes various user input 
and
: : builds a query. one of the things the user can input is some keywords
: : and this is where i am having some problems, the code is below:
: :
: : If Request.form("keyword") <> "" Then
: :   Dim searchwords
: :   tempinput=Request.form("keyword")
: :   searchwords=split(tempinput," ")
: :   maxcounter=ubound(searchwords)
: :   whereclause=" and keywords like '%" & searchwords(0) & "%'"
: :   FOR counter=1 TO maxcounter
: :       thissearchword=searchwords(counter)
: :       whereclause=whereclause & " OR keywords like '%" & 
thissearchword
: : & "%'"
: :   NEXT
: : strQuery = strQuery + whereclause
: : End If
: :
: : the problem i am having is that i would like to put an initial value
: : into the keyword textarea on the page, eg. enter keywords however 
when i
: : do this i get the following error :
: :
: : Error Type:
: : Microsoft VBScript runtime (0x800A0009)
: : Subscript out of range: '[number: 0]'
: :
: : Now my understanding is that if i used: "If Request.form("keyword") <>
: : "enter keywords" Then" that part of the script would not be entered 
when
: : the initial value had not been changed from enter keywords.
: :
: : if anyone can shed some light on what is probably a very simple 
problem,
: : i would be forever in your debt.
: :
: : many thanks in advance
: :
: : g


Message #8 by "Ken Schaefer" <ken@a...> on Fri, 4 Oct 2002 13:11:21 +1000
String comparisons are case sensitive, are you sure you have the case
exactly the same? You can use LCase() to force both to be lower case.

Also, make sure you have no leading or trailing whitespace but using the
Trim() function

Cheers
Ken

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: <propellerhead@b...>
Subject: [asp_web_howto] Re: Help please...


: Ken you are correct, i didn't post my message very well...
:
: when i use If request.form("keyword")<> "" then...
:
: everything worked ok, i wasn't getting the out of range error but as soon
: as i changed it to If request.form("keyword")<> "Enter keywords" then...
: i would get the error...
:
: so... i have as my initial value in the form element "keyword" "Enter
: keywords" i am wondering why the code within the If statement is being
: processed as the condition should be false i.e. request.form("keyword")
: does infact equal Enter keywords...
:
: eternally confused

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Message #9 by propellerhead@b... on Fri, 4 Oct 2002 04:35:04
thanks, i'll try it out.

g

> String comparisons are case sensitive, are you sure you have the case
exactly the same? You can use LCase() to force both to be lower case.

Also, make sure you have no leading or trailing whitespace but using the
Trim() function

Cheers
Ken

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: <propellerhead@b...>
Subject: [asp_web_howto] Re: Help please...


: Ken you are correct, i didn't post my message very well...
:
: when i use If request.form("keyword")<> "" then...
:
: everything worked ok, i wasn't getting the out of range error but as 
soon
: as i changed it to If request.form("keyword")<> "Enter keywords" then...
: i would get the error...
:
: so... i have as my initial value in the form element "keyword" "Enter
: keywords" i am wondering why the code within the If statement is being
: processed as the condition should be false i.e. request.form("keyword")
: does infact equal Enter keywords...
:
: eternally confused

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


  Return to Index