jr_dunson has asked for the wisdom of the Perl Monks concerning the following question:

Hey, I've run into an error with the IIS Server on my PC when using Perl ActiveState Here is the code I'm using in two separate CGI pages:
------------------------------------------------------------
1. Here is the basic: CGI form screen:
------------------------------------------------------------
#!/usr/local/bin/perl -w our $html = ""; our $htmln = ""; $html =<<EOF; Content-Type: text/html\n\n <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http:// +www.w3.org/TR/REC-html40/loose.dtd"> <HTML> <HEAD> <TITLE> Forms-Search </TITLE> </HEAD> <BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#800080" +ALINK="#FF0000"> <hr> EOF $htmln =<<EOF; <hr> <FORM ACTION="forms_rpt.cgi" METHOD="post" TARGET="_self"> <table width: 60% border="0" cellpadding="2" cellspacing="2"> <tr> <td>Form:</td> <td><input maxlength="10" size="10" name="fname"></td> </tr> <tr> <td>Title:</td> <td><input maxlength="10" size="10" name="form_title"></td> </tr> <tr> <td>Form Type:</td> <td align="left"> <select name="form_type"> <option value="all" selected>All</option> <option value="frl">FormFlow</option> <option value="xfdl">IBM WorkForms</option> <option value="xsn">Infopath</option>s <option value="pdf">PDF</option> <option value="jtp">JetForm</option> <option value="xfdl">Pureedge</option> <option value="doc">Word Document</option> </select> </td> </tr> </table> <br> <br> <br><br> <input type="submit" name="Submit" value="Submit"> </FORM> <HR> <P><SMALL>Created on ... April 01, 2006</SMALL></P> EOF $html .= $htmln; $htmln =<<EOF; </html></body> EOF $html .= $htmln; print $html;
---------------------------------------------------------------
2. Here is the second cgi:
---------------------------------------------------------------
#!/usr/local/bin/perl -w use CGI; # load CGI routines use DBI; use DBD::ODBC; my $cweb = CGI->new(); my $fname = $cweb->param('fname'); my $form_title = $cweb->param('form_title'); my $form_type = $cweb->param('form_type'); my $driver = "mysql"; my $server = "localhost"; my $database = "train"; my $url = "DBI:$driver:$database:$server"; my $user = ""; #--- taken out intentionally my $password = ""; #--- taken out intentionally our $db1 = DBI->connect( $url, $user, $password ) or die "Failure!\n"; our $html = ""; our $htmln = ""; our $hdr = 0; $html =<<EOF; Content-Type: text/html\n\n <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http:// +www.w3.org/TR/REC-html40/loose.dtd"> <HTML> <HEAD> <TITLE>Forms-Search Results</TITLE> <LINK REV="made" HREF="mailto:jarrell_dunson@ky.ngb.army.mil"> </HEAD> <BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#800080" +ALINK="#FF0000"> <hr> EOF #---------------------- test printout only $htmln = <<EOF; <hr> $fname<br> $form_title<br> $form_type<br> EOF $html .= $htmln; our %s_info; our $s_ref; $STMT3 = <<EOF; SELECT form_table.fname, form_table.title, form_table.desc, form_rec.form_url, form_rec.form_type FROM form_table, form_rec WHERE form_table.fname = form_rec.fname and form_table.fname LIKE '%$fname%' EOF if ($form_type ne "all") { my $ft_upper = uc($form_type); $STMT3a = <<EOF; and ((form_type = '$form_type') or (form_type = '$ft_upper')) EOF $STMT3 .= $STMT3a; } $sth3 = $db1->prepare($STMT3); if ( !defined($sth3) ) { warn join (" ",'ERROR', $db1->errstr, "$S +TMT3"); return 1; } $sth3->execute(); while($s_ref = $sth3->fetchrow_hashref) { %s_info = %$s_ref; if ($hdr == 0) { $htmln =<<EOF; <table width: 80%; border="1" cellpadding="2" cellspacing="1"> <tr> <td>File Name</td> <td>Title</td> <td>Description</td> <td>File Type</td> </tr> EOF $html .= $htmln; $hdr = 1 } #------------------------------------ Rows $htmln =<<EOF; <tr> <td><A HREF="$s_info{form_url}" TARGET="_blank" title="Go to $s_ +info{fname}">$s_info{fname}</A></td> <td>$s_info{title}</td> <td>$s_info{desc}</td> <td>$s_info{form_type}</td> </tr> EOF $html .= $htmln; #-------------------------------- end Rows } $htmln = <<EOF; </table> EOF $html .= $htmln; $htmln = <<EOF; <br> </body> </html> EOF $html .= $htmln; print $html; $db1->disconnect(); ------------------------------------------------------------
I've traced the errors to two points, though I haven't worked out why they are related to each other: a) The code works find for most input into the first text box. The first text box populates $fname. However, I enter the letter 'a' ...which looks like this, for the SQL statement:
SELECT form_table.fname, form_table.title, form_table.desc, form_rec.f +orm_url, form_rec.form_type FROM form_table, form_rec WHERE form_tabl +e.fname = form_rec.fname and form_table.fname LIKE '%a%'
I get a error: The page cannot be displayed The page you are looking for is currently unavailable. The Web site might be experiencing technical difficulties, or you may need to adjust your browser settings.... ...HOWEVER, if I change the output for rows a follows:
#------------------------------------ Rows $htmln =<<EOF; <tr> <td><A HREF="$s_info{form_url}" TARGET="_blank" title="Go to $s_ +info{fname}">$s_info{fname}</A></td> <td>$s_info{title}</td> <td>&nbsp;</td> #<---changed this line <td>$s_info{form_type}</td> </tr> EOF $html .= $htmln;
The code works fine..... Note: I replaced the third cell from
from <td>$s_info{desc}</td>
to
<td>&nbsp;</td>
$s_info{desc} is a char field in mySql. I've even noticed that, when using the letter a, the page will cause the same error if I use the code:
#------------------------------------ Rows $htmln =<<EOF; <tr> <td><A HREF="$s_info{form_url}" TARGET="_blank" title="Go to $s_ +info{fname}">$s_info{fname}</A></td> <td>$s_info{title}</td> <td>$s_info{title}</td> #<---repeated the prev <td> input <td>$s_info{form_type}</td> </tr> EOF $html .= $htmln;
...which makes me wonder if some problem in reading the $s_info object... thanks, Jarrell

Edited by planetscape - added readmore tags

Replies are listed 'Best First'.
Re: IIS Like Error using Perl Active State w/ SQL Server or MySQL
by jfroebe (Parson) on Apr 28, 2006 at 18:42 UTC

    Hi,

    Can you post the perl code snippet you are trying to use? Otherwise, it makes it rather difficult for us to help you.

    thanks :)

    Jason L. Froebe

    Team Sybase member

    No one has seen what you have seen, and until that happens, we're all going to think that you're nuts. - Jack O'Neil, Stargate SG-1

Re: IIS Like Error using Perl Active State w/ SQL Server or MySQL
by Asim (Hermit) on Apr 28, 2006 at 20:39 UTC

    In addition to jfroebe's comment, I also recommend three basic pieces of debugging advice:

    • I'd change our $db1 = DBI->connect( $url, $user, $password ) or die "Failure!\n"; to be explicit about failures with our $db1 = DBI->connect( $url, $user, $password, {RaiseError => 1} ) or die "Failure!\n";*,
    • use CGI::Carp qw(fatalsToBrowser); to have the browser show you what Perl thinks of the crashes.
    • Trigger tracing with DBI via something like DBI->trace(1, 'dbi.log');, to show you details of the transactions.

    I know it sounds like a great deal of work, but it can make a huge difference in how you debug your code. And in how much we can help you. :)

    * As I recall, some DBD modules have it on by default, others off. Better safe than sorry.

    ----Asim, known to some as Woodrow.

      Thanks for the tips, I'll try it. JRD