Gossamer Forum
Home : Products : Gossamer Links : Discussions :

can't loop for over 16 times when debug_level set to 1

Quote Reply
can't loop for over 16 times when debug_level set to 1
I am running Links SQL 2.12.

I wrote a small script. Some codes as follows:

my $db = $DB->table('Quiz');
for ($i=1; $i<=40; $i++) {
$sth = $db->get($i);
if ($sth) {... }
else {... }
....
}

The first column of table('Quiz') is ID, from 1 to 40.

Everything worked fine until I set debug_level to 1. It kept running but didn't do anything and no error message. When I set debug_level back to 0, it worked again. Then I changed $i. If I set $i<=16, it worked. If I set $i<=17, it didn't work. I checked all the records of the table, there was nothing wrong. At last, I found that ($i=20; $i<=36; $i++) will work. But ($i=20; $i<=37; $i++) won't work.

It means it can't loop for over 16 times when I set debug_level to 1. Why this happens?

Any help is greatly appreciated.
Quote Reply
Re: [Fortune] can't loop for over 16 times when debug_level set to 1 In reply to
Hi,

Hmm, can you run the program from shell? Does it complete normally? If debug is on do you see the error output?

Only reason I can think of that debug would kill the program is if it was causing it to go over some memory limit.

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] can't loop for over 16 times when debug_level set to 1 In reply to
Hi Alex,

I tried a simple code as follows to test it:

sub handle {
# --------------------------------------------------------------
my ($i, $sth, $output);
my $db = $DB->table('Quiz');
for ($i=1; $i<=17; $i++) {
$sth = $db->get($i);
if ($sth) {
$output .= "$sth->{Question}<BR>\n";
}
}
print $IN->header();
print "$output\n\n";
}

It didn't work from the browser (IE6.0). When I ran it from shell, it said:

GT::SQL::Driver::MYSQL::sth (28746): Executing query: SELECT * FROM lsql_Quiz WHERE ( ID = 1 ) from Links::User::Quiz::handle at admin/Links/User/Quiz.pm line 12

There were totally 17 messages showed as the above, and then showed the correct output.

When I was going to submit this post, I tried it again from Netscape Communicator 4.76. It worked. Then when I increase $i to 40, It stopped working. Actually, It stopped working from Netscape when $i>=22.

Last edited by:

Fortune: Mar 19, 2003, 2:04 AM
Quote Reply
Re: [Fortune] can't loop for over 16 times when debug_level set to 1 In reply to
You'd be better removing that for() loop and just using LIMIT in your select clause.

Last edited by:

Paul: Mar 19, 2003, 2:04 AM
Quote Reply
Re: [Fortune] can't loop for over 16 times when debug_level set to 1 In reply to
Thank you, Paul. I did change it to $db->select_options as you suggested. It worked great.

Just wonder if there are problems in debug_level or get().