ASP Include Problems

M

Max Hazelhurst

Hi there,

Got an include file causing a timeout on the server when it's called on...

The code has a loop in it that I suspect may be the cause...

I can forward the entire inc file should it be necessary...

Many thanks as ever..
Max
Maxh att zelhurst dott com



if (user_id = "") Then
loggedin=false
do
user_id=generateID(5)
user_sql="SELECT tbl_user.user_id FROM
tbl_user WHERE ((tbl_user.user_id)=" & user_id & ");"
loop while db_validate(user_id, user_sql)

user_sql= "INSERT INTO tbl_user (user_id,
username, lastipaddress, lastcompname, expires )VALUES "
user_sql= user_sql & "('" & user_id & "','" &
"','" & Request.ServerVariables("REMOTE_ADDR") & "','" &
Request.ServerVariables("REMOTE_USER") & "','" & user_expires &
"');"
conn.Execute(user_sql)
end if
 
C

Chris Barber

<woeful-plea instyleof="Shakespearian Tragedy">
Doesn't anybody care about code readability, comments, case, error
handling, and variable declaration anymore?
</woeful-plea>

What is the function db_validate() that provides the loop exit point?

In order to debug you need to fix your code first by making judicious use
of:

Option Explicit
Dimension your variables
Place comments in the code to say what's going on.
Never have loops that don't have a 'get out' clause (eg. after 5 seconds
or 1000 loops etc.).
Include error traps to detect errors after SQL executions (implies use
of On Error Resume Next).

I'm not having a go at *you* but your post is symptomatic of a lot of very
short requests for help that are patently impossible to comment on without
the request for 'a short code section that is self-contained and
demonstrates the issue'.

To be honest, you seem to have found the issue already - examine your loop
response in debug mode and I'm sure you'll find the source of the problem.
At the very least put a get out clause in that allows you to report and
process the error (if it's an error that's occurring).

Regards,

Chris Barber.


Hi there,

Got an include file causing a timeout on the server when it's called on...

The code has a loop in it that I suspect may be the cause...

I can forward the entire inc file should it be necessary...

Many thanks as ever..
Max
Maxh att zelhurst dott com



if (user_id = "") Then
loggedin=false
do
user_id=generateID(5)
user_sql="SELECT tbl_user.user_id FROM
tbl_user WHERE ((tbl_user.user_id)=" & user_id & ");"
loop while db_validate(user_id, user_sql)

user_sql= "INSERT INTO tbl_user (user_id,
username, lastipaddress, lastcompname, expires )VALUES "
user_sql= user_sql & "('" & user_id & "','" &
"','" & Request.ServerVariables("REMOTE_ADDR") & "','" &
Request.ServerVariables("REMOTE_USER") & "','" & user_expires &
"');"
conn.Execute(user_sql)
end if
 
C

Chris Barber

Just so I don't come across as a complete moron, I've already apologised to David for my harsh post having started and email discussion. Turns out that it's not his code (as I should have suspected) but as usual belongs to 'another' developer

<quote>
This is a bit of a strange one as I've inherited the maintenance of this site from another developer who is not around to advise...
</quote>
Of course ... we're all just fixing someone else's code. Seems like the industry has found a way to self-perpetuate. I write bad code and come back 2 years later to a new boss and fix it thus getting paid twice (unless I'm daft enough to leave my name in the comments of course). Wasn't me honestly, it was my evil twin brother ...

LoL.

After feeling guilty for a few mins 'we' may have found a suspect loop that appears to run indefinitely in certain circumstances thus hanging ASP.

Chris.

<woeful-plea instyleof="Shakespearian Tragedy">
Doesn't anybody care about code readability, comments, case, error
handling, and variable declaration anymore?
</woeful-plea>

What is the function db_validate() that provides the loop exit point?

In order to debug you need to fix your code first by making judicious use
of:

Option Explicit
Dimension your variables
Place comments in the code to say what's going on.
Never have loops that don't have a 'get out' clause (eg. after 5 seconds
or 1000 loops etc.).
Include error traps to detect errors after SQL executions (implies use
of On Error Resume Next).

I'm not having a go at *you* but your post is symptomatic of a lot of very
short requests for help that are patently impossible to comment on without
the request for 'a short code section that is self-contained and
demonstrates the issue'.

To be honest, you seem to have found the issue already - examine your loop
response in debug mode and I'm sure you'll find the source of the problem.
At the very least put a get out clause in that allows you to report and
process the error (if it's an error that's occurring).

Regards,

Chris Barber.


Hi there,

Got an include file causing a timeout on the server when it's called on...

The code has a loop in it that I suspect may be the cause...

I can forward the entire inc file should it be necessary...

Many thanks as ever..
Max
Maxh att zelhurst dott com



if (user_id = "") Then
loggedin=false
do
user_id=generateID(5)
user_sql="SELECT tbl_user.user_id FROM
tbl_user WHERE ((tbl_user.user_id)=" & user_id & ");"
loop while db_validate(user_id, user_sql)

user_sql= "INSERT INTO tbl_user (user_id,
username, lastipaddress, lastcompname, expires )VALUES "
user_sql= user_sql & "('" & user_id & "','" &
"','" & Request.ServerVariables("REMOTE_ADDR") & "','" &
Request.ServerVariables("REMOTE_USER") & "','" & user_expires &
"');"
conn.Execute(user_sql)
end if
 
B

Bullschmidt

Don't know if this would help at all:

' Script timeout in seconds for this page.
' (60 x 60 = 1 hour.)
Server.ScriptTimeout = 60 * 60

Best regards,
J. Paul Schmidt, Freelance ASP Web Developer
http://www.Bullschmidt.com
ASP Design Tips, ASP Web Database Demo, Free ASP Bar Chart Tool...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top