Newbie question on Apache::Debug::dump

2000-08-19 Thread Jay Strauss

Sorry if this has been asked before but I have been unable to find the answer
(not in perldoc, apache modules book, searching archives):

I would like my perl compilation and process errors to be written to an HTML
page if/when they occur, in the same way they are written to stdout when I run
from the command line.

I thought that Apache::Debug::dump would do this, am I correct??

I am unable to make it work though.  I can't seem to find any examples of how to
use it, perldoc is too brief for my limited skills, the apache modules book
(eagle) says:

"The three arguments to dump() are the request object, an error code to return
to Apache... and an error message..."

What is a "request object"?

No matter what I do, all I can produce is that "OK" server error page.  My perl
code is a simple: give userid, password, database, sql query, connect to my
database (oracle) and display the results.

Can someone please give me an example of how to use dump()? Or if you have a
different suggestion.

Appended is my simple perl code and HTML error page

Thanks
Jay

Jay Strauss
[EMAIL PROTECTED]
(h) 773.935.5326
(c) 312.617.0264


#!/usr/bin/perl -w

use strict;
use Apache::Constants qw(:common);
use Apache::Registry;
use Apache::Debug;
use DBI;

print "Content-Type: text/html\n\n";
print "HTML\n";
print "BODY\n";

my $r = shift;
my %input = $r-method eq 'POST' ? $r-content : $r-args;

$ENV{ORACLE_HOME} = "/u01/app/oracle/product/8.1.6";

my $dbh =
DBI-connect("dbi:Oracle:$input{servicename}",$input{userid},$input{password})
or Apache::Debug::dump($dbh,SERVER_ERROR,"Can not connect to database $input
{servicename}");

my $sqlh = $dbh-prepare($input{query});
my $rc = $sqlh-execute;

print "table border=1\n";

foreach my $ColumnName (@{$sqlh-{NAME}}){
   print "td align=left$ColumnName";
}

while (my @row = $sqlh-fetchrow_array()){
   print "tr\n";
   foreach my $column (@row) {

while (my @row = $sqlh-fetchrow_array()){
   print "tr\n";
   foreach my $column (@row) {
 print "td$column/td";
   }
   print "/tr\n";
}

warn "Problem in fetchrow_array(): ", $sqlh-errstr(), "\n"
if $sqlh-err();

print "/table\n";

$dbh-disconnect;

print "/BODY\n";
print "/HTML\n";

exit;

The error page HTML
---
HTML
BODY
HTTP/1.1 200 OK
Date: Sat, 19 Aug 2000 16:36:10 GMT
Server: Apache/1.3.12 (Unix) mod_perl/1.24
Connection: close
Transfer-Encoding: chunked
Content-Type: text/html; charset=iso-8859-1

!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"
HTMLHEAD
TITLE200 OK/TITLE
/HEADBODY
H1OK/H1
The server encountered an internal error or
misconfiguration and was unable to complete
your request.P
Please contact the server administrator,
 [EMAIL PROTECTED] and inform them of the time the error occurred,
and anything you might have done that may have
caused the error.P
More information about this error may be available
in the server error log.P
HR
ADDRESSApache/1.3.12 Server at abba.hostdb.com Port 80/ADDRESS
/BODY/HTML




Re: Newbie question on Apache::Debug::dump

2000-08-19 Thread Craig McLane

The request object is $r

Craig


On Sat, 19 Aug 2000, Jay Strauss wrote:

 Sorry if this has been asked before but I have been unable to find the answer
 (not in perldoc, apache modules book, searching archives):
 
 I would like my perl compilation and process errors to be written to an HTML
 page if/when they occur, in the same way they are written to stdout when I run
 from the command line.
 
 I thought that Apache::Debug::dump would do this, am I correct??
 
 I am unable to make it work though.  I can't seem to find any examples of how to
 use it, perldoc is too brief for my limited skills, the apache modules book
 (eagle) says:
 
 "The three arguments to dump() are the request object, an error code to return
 to Apache... and an error message..."
 
 What is a "request object"?
 
 No matter what I do, all I can produce is that "OK" server error page.  My perl
 code is a simple: give userid, password, database, sql query, connect to my
 database (oracle) and display the results.
 
 Can someone please give me an example of how to use dump()? Or if you have a
 different suggestion.
 
 Appended is my simple perl code and HTML error page
 
 Thanks
 Jay