Re: Blank Pages ( Revisited ) [Semi-OT]
Hi there, On Wed, 13 Mar 2002 [EMAIL PROTECTED] wrote: However, when I do a random query I get some blank pages. I traced this to the DBI Log using the DBH-Trace(2, /tmp/DBI.log). I found that sometimes the execute() returns 0E0. Does anybody knows why?? It probably means zero multiplied by ten to the power zero, or to put it another way, zero. 73, Ged.
Re: Blank Pages ( Revisited ) [Semi-OT]
On Wed, 13 Mar 2002 10:29:51 + (GMT), Ged Haywood wrote: Hi there, On Wed, 13 Mar 2002 [EMAIL PROTECTED] wrote: However, when I do a random query I get some blank pages. I traced this to the DBI Log using the DBH-Trace(2, /tmp/DBI.log). I found that sometimes the execute() returns 0E0. Does anybody knows why?? It's DBI's way of saying 0 (records returned) but true. Ie It's deliberate. -- Ron Savage, [EMAIL PROTECTED] on 13/3/02 http://savage.net.au/index.html
Re: Blank Pages ( Revisited ) [Semi-OT]
However, when I do a random query I get some blank pages. I traced this to the DBI Log using the DBH-Trace(2, /tmp/DBI.log). I found that sometimes the execute() returns 0E0. Does anybody knows why?? It probably means zero multiplied by ten to the power zero, or to put it another way, zero. Perl has three values that are false: 0, and undef. Anything else is true. OE0 is the 0 but true value that DBI uses to signal that zero rows were returned, but succeeded. xoxo, Andy -- 'Andy Lester[EMAIL PROTECTED] Programmer/author petdance.com Daddy parsley.org/quinn Jk'=~/.+/s;print((split//,$) [unpack'C*',n2]3%+\34.'%.'^%4+!o.'])
Re: Blank Pages ( Revisited )
On Wed, 13 Mar 2002 [EMAIL PROTECTED] wrote: Date: Wed, 13 Mar 2002 06:07:01 GMT From: [EMAIL PROTECTED] To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: Blank Pages ( Revisited ) In the past someone posted a problem with mod_perl and DbI giving blank pages from a SQL query. I did some digging around and found some info but I need someone to fill in the holes for me a little. I created a DB Table webtest. In the table, I filled it with the contents of /usr/local/dict/propernames. Fine! it worked beautifully. However, when I do a random query I get some blank pages. I traced this to the DBI Log using the DBH-Trace(2, /tmp/DBI.log). I found that sometimes the execute() returns 0E0. Does anybody knows why?? I did a simple logic to check for the value return by execute(), if the value is 0E0 then do the same query. Do this same query until the value return by execute() is not 0E0. However, I am still getting blank pages. I am sending the actual script that I have been working on to provide a complete picture. Thank you in advanced A floating point 0 or 0E0 is sometimes returned since it will test as True, when then number is unknown. Someone who undersands DBI's innards may comment on if this is the case here. -max SCRIPT== 1 package DBNE2; 2 3 use strict; 4 use vars qw($DBH); 5 use Apache; 6 use DBI(); 7 8 sub handler { 9 $DBH = DBI-connect(DBI:mysql:test,webuser,mult1scan) || die $DBH-errstr; 10 my $r = shift; 11 my $h = $DBH-trace(2,/tmp/DBNE2.log); 12 13 my $IdHandle = $DBH-prepare(SELECT MAX(id) FROM webtest); 14 $IdHandle-execute; 15 my $id = $IdHandle-fetchrow; 16 17 my $RowHandlesth = $DBH-prepare(SELECT * FROM webtest WHERE id = ROUND( (RAND() * ?) + 1)); 18 $RowHandlesth-execute($id); 19 20 while (! $RowHandlesth ) { 21 $RowHandlesth-execute($id); 22 23 if ( $RowHandlesth ) { 24 # my @row = $RowHandlesth-fetchrow; 25 last; 26 } 27 } 28 my @row = $RowHandlesth-fetchrow; 29 30 $r-content_type(text/html); 31 $r-send_http_header; 32 $r-print(@row); 33 $RowHandlesth-finish; 34 } 35 36 1; Sincerely, William Mussatto, Senior Systems Engineer CyberStrategies, Inc ph. 909-920-9154 ext. 27
Re: Blank Pages ( Revisited )
However, when I do a random query I get some blank pages. I traced this to the DBI Log using the DBH-Trace(2, /tmp/DBI.log). I found that sometimes the execute() returns 0E0. Does anybody knows why?? If I remember rightly 0E0, in DBI, means Success ie : your query worked, but no rows were affected/returned. If there had been an error, undef would be returned. So for some reason your query is returning no rows. Can't immediately see why. (0E0 is evaluated as TRUE in a Boolean statement, undef as false.) HTH Henry I did a simple logic to check for the value return by execute(), if the value is 0E0 then do the same query. Do this same query until the value return by execute() is not 0E0. However, I am still getting blank pages. I am sending the actual script that I have been working on to provide a complete picture. Thank you in advanced -max SCRIPT== 1 package DBNE2; 2 3 use strict; 4 use vars qw($DBH); 5 use Apache; 6 use DBI(); 7 8 sub handler { 9 $DBH = DBI-connect(DBI:mysql:test,webuser,mult1scan) || die $DBH-errstr; 10 my $r = shift; 11 my $h = $DBH-trace(2,/tmp/DBNE2.log); 12 13 my $IdHandle = $DBH-prepare(SELECT MAX(id) FROM webtest); 14 $IdHandle-execute; 15 my $id = $IdHandle-fetchrow; 16 17 my $RowHandlesth = $DBH-prepare(SELECT * FROM webtest WHERE id = ROUND( (RAND() * ?) + 1)); 18 $RowHandlesth-execute($id); 19 20 while (! $RowHandlesth ) { 21 $RowHandlesth-execute($id); 22 23 if ( $RowHandlesth ) { 24 # my row = $RowHandlesth-fetchrow; 25 last; 26 } 27 } 28 my row = $RowHandlesth-fetchrow; 29 30 $r-content_type(text/html); 31 $r-send_http_header; 32 $r-print(row); 33 $RowHandlesth-finish; 34 } 35 36 1; __ Do You Yahoo!? Everything you'll ever need on one web page from News and Sport to Email and Music Charts http://uk.my.yahoo.com
Re: Blank Pages ( Revisited )
On Wed, Mar 13, 2002 at 06:07:01AM +, [EMAIL PROTECTED] wrote: In the past someone posted a problem with mod_perl and DbI giving blank pages from a SQL query. I did some digging around and found some info but I need someone to fill in the holes for me a little. I created a DB Table webtest. In the table, I filled it with the contents of /usr/local/dict/propernames. Fine! it worked beautifully. However, when I do a random query I get some blank pages. I traced this to the DBI Log using the DBH-Trace(2, /tmp/DBI.log). I found that sometimes the execute() returns 0E0. Does anybody knows why?? I did a simple logic to check for the value return by execute(), if the value is 0E0 then do the same query. Do this same query until the value return by execute() is not 0E0. However, I am still getting blank pages. SELECT queries return 0E0 from execute() to indicate success, because the actual number of rows is not known until you fetch them. UPDATE and DELETE queries return 0E0 from execute() when the execution was successful but no rows were affected. You're probably getting a blank page because no row is being found. This could happen if there are gaps in ids in the table. It could also happen if rand() returns a number close to 1, because you're using ROUND() when you should be using TRUNC(). Also, the logic in this section of the code does not make sense: 17 my $RowHandlesth = $DBH-prepare(SELECT * FROM webtest WHERE id = ROUND( (RAND() * ?) + 1)); 18 $RowHandlesth-execute($id); 19 20 while (! $RowHandlesth ) { 21 $RowHandlesth-execute($id); If $RowHandlesth is false, it's because prepare() returned undef. You can't call a method on the undefined value. On the other hand, at least this will cause a fatal error; otherwise you would have an infinite loop, because once you enter the loop $RowHandlesth will never become true. 22 23 if ( $RowHandlesth ) { You entered the loop because $RowHandlesth was false, and you haven't changed it's value since entering the loop. How could it be true all of a sudden? 24 # my @row = $RowHandlesth-fetchrow; If this line were not commented out, you would be assigning to a lexical @row which would go out of scope right after. 25 last; 26 } 27 } 28 my @row = $RowHandlesth-fetchrow; Ronald
RE: Blank pages
i ran into a number of similar problems that did not seem to be documented anywhere else. in my case, we had a number of scripts that would change STDOUT in some fashion (usually so they could set $|) but then die due to some error before resetting STDOUT back. then any mod-perl script that the child would serve would produce a blank page while static files would continue to be served cleanly. when that child died, the problem would go away. if a user refreshed and got another child, then it would appear as if the problem went away. i added the PID to the access logs and watched for any HTTP 200's with zero length body sizes and traced backwards to see who the common culprit was. the only caveat was that apache would sometimes log HTTP 200 when in fact the return code was HTTP 302 (redirect). it is natural to have a zero length body size for a redirect. good luck, John E. Leon Guerrero -Original Message- From: Axel Andersson [mailto:[EMAIL PROTECTED]] Sent: Friday, March 01, 2002 5:40 AM To: [EMAIL PROTECTED] Subject: Blank pages Hi, I run a mod_perl/mysql site, which works fine most of the time. Some pages, however, come out completely blank. Reload.. and hey presto, it works. Now, I realize this could be practically anything, so I'm just asking if anyone has come across something similar. I use Apache::DBI 0.88 for database connections, Apache 1.3.23 and mod_perl/1.2. Strange thing is, nothing shows up in the error log, even using -w. Well, it's a longshot, but thanks anyway. Axel Andersson -- [EMAIL PROTECTED] http://www.animanga.nu/morris/ 31. With intagible breath in center of forehead, as this reaches heart at the moment of sleep, have direction over dreams and over death itself.
Re: Blank pages
John E Leon Guerrero wrote: in my case, we had a number of scripts that would change STDOUT in some fashion (usually so they could set $|) but then die due to some error before resetting STDOUT back Interesting One safety measure to prevent this would be to install a cleanup handler that resets STDOUT This is a similar concept to the rollback that Apache::DBI issues in a cleanup handler - Perrin
Re: Blank pages
Ged Haywood writes: Hi there, On Fri, 1 Mar 2002, Axel Andersson wrote: I run a mod_perl/mysql site, which works fine most of the time. Some pages, however, come out completely blank. Reload.. and hey presto, [snip] Well, it's a longshot, but thanks anyway. Another long shot, do you always specify full paths to files in your code? If you don't get anywhere with that then I'd suggest looking at the debugging section of the Guide: http://prel.apache.org/guide and/or peppering your code at strategic places with 'print STDERR $something_useful\n' statements. 73, Ged. I have been getting the same problems with the same setup ( Mod_Perl / MySQL). But I am having a little fun with this setup. I populated a small table in the 'test' DB in MySQL withe the contents of '/usr/local/share/dict/propernames'. I then have the script to randomly chose an id from the DB table and then to select a row of info. I will post the scipt contents and some debugging data to give some more info on the internal processes. The Script is : 1 package DBNE; 2 3 use strict; 4 use vars qw($DBH); 5 use Apache; 6 #use Apache::File; 7 use DBI(); 8 9 sub handler { 10 $DBH = DBI-connect(DBI:mysql:test,webuser,mult1scan) || die $DBH-errstr; 11 my $r = shift; 12 my $h = $DBH-trace(5,/tmp/DBI.log); 13 14 $r-send_http_header; 15 my $sth = $DBH-prepare(SELECT MAX(id) FROM webtest); 16 $sth-execute; 17 my ($id) = $sth-fetchrow; 18 19 my $sth = $DBH-prepare(SELECT * FROM webtest WHERE id = ROUND( (RAND() * $id) + 1)); 20 $sth-execute; 21 22 my ($id,$name,$last,$town) = $sth-fetchrow; 23 $r-print($id\t\t $name\t\t $last\t\t $town \n); 24 $sth-finish; 25 26 } 27 28 1; The debuging info is: - DESTROY= undef at /home/mcalvo/ModPerl/DBNE.pm line 11 DBI::db=HASH(0x81faf3c) trace level set to 5 in DBI 1.20-nothread Note: perl is running without the recommended perl -w option - prepare for DBD::mysql::db (DBI::db=HASH(0x81e90e4)~0x81faf3c 'SELECT MAX(id) FROM webtest') dbih_setup_handle(DBI::st=HASH(0x8156390)=DBI::st=HASH(0x81e90d8), DBD::mysql::st, 81faef4, Null!) dbih_make_com(DBI::db=HASH(0x81faf3c), DBD::mysql::st, 204) dbih_setup_attrib(DBI::st=HASH(0x81e90d8), Err, DBI::db=HASH(0x81faf3c)) SCALAR(0x818bc78) (already defined) dbih_setup_attrib(DBI::st=HASH(0x81e90d8), State, DBI::db=HASH(0x81faf3c)) SCALAR(0x81aef9c) (already defined) dbih_setup_attrib(DBI::st=HASH(0x81e90d8), Errstr, DBI::db=HASH(0x81faf3c)) SCALAR(0x818bc54) (already defined) dbih_setup_attrib(DBI::st=HASH(0x81e90d8), Handlers, DBI::db=HASH(0x81faf3c)) ARRAY(0x81e90b4) (already defined) dbih_setup_attrib(DBI::st=HASH(0x81e90d8), Debug, DBI::db=HASH(0x81faf3c)) 5 (already defined) dbih_setup_attrib(DBI::st=HASH(0x81e90d8), FetchHashKeyName, DBI::db=HASH(0x81faf3c)) 'NAME' (already defined) Setting mysql_use_result to 0 - prepare= DBI::st=HASH(0x8156390) at /home/mcalvo/ModPerl/DBNE.pm line 15 - execute for DBD::mysql::st (DBI::st=HASH(0x8156390)~0x81e90d8) - dbd_st_execute for 081fac90 - dbd_st_execute 1 rows - execute= 1 at /home/mcalvo/ModPerl/DBNE.pm line 16 - fetchrow for DBD::mysql::st (DBI::st=HASH(0x8156390)~0x81e90d8) - dbd_st_fetch for 081fac90, chopblanks 0 dbih_setup_fbav for 1 fields = 0x8135854 Storing row 0 (1323) in 081fae64 - dbd_st_fetch, 1 cols - fetchrow= ( '1323' ) [1 items] row1 at /home/mcalvo/ModPerl/DBNE.pm line 17 - prepare for DBD::mysql::db (DBI::db=HASH(0x81e90e4)~0x81faf3c 'SELECT * FROM webtest WHERE id = ROUND( (RAND() * 1323) + 1)') dbih_setup_handle(DBI::st=HASH(0x81faf90)=DBI::st=HASH(0x81faf24), DBD::mysql::st, 81faf78, Null!) dbih_make_com(DBI::db=HASH(0x81faf3c), DBD::mysql::st, 204) dbih_setup_attrib(DBI::st=HASH(0x81faf24), Err, DBI::db=HASH(0x81faf3c)) SCALAR(0x818bc78) (already defined) dbih_setup_attrib(DBI::st=HASH(0x81faf24), State, DBI::db=HASH(0x81faf3c)) SCALAR(0x81aef9c) (already defined) dbih_setup_attrib(DBI::st=HASH(0x81faf24), Errstr, DBI::db=HASH(0x81faf3c)) SCALAR(0x818bc54) (already defined) dbih_setup_attrib(DBI::st=HASH(0x81faf24), Handlers, DBI::db=HASH(0x81faf3c)) ARRAY(0x81e90b4) (already defined) dbih_setup_attrib(DBI::st=HASH(0x81faf24), Debug, DBI::db=HASH(0x81faf3c)) 5 (already defined) dbih_setup_attrib(DBI::st=HASH(0x81faf24), FetchHashKeyName, DBI::db=HASH(0x81faf3c)) 'NAME' (already defined) Setting mysql_use_result to 0 - prepare= DBI::st=HASH(0x81faf90) at /home/mcalvo/ModPerl/DBNE.pm line 19 - execute for DBD::mysql::st (DBI::st=HASH(0x81faf90)~0x81faf24) - dbd_st_execute for 081e9084 - dbd_st_execute 0 rows - execute= '0E0' at /home/mcalvo/ModPerl/DBNE.pm line 20 - fetchrow for DBD::mysql::st