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


In reply to IIS Like Error using Perl Active State w/ SQL Server or MySQL by jr_dunson

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.