Hello I am trying to write my first perl script using CGI, DBI and DBD::ODBC to connect to an Oracle database on my Windows XP pc.
I have got simple CGI scripts working on here but this is the first trying to connect to a database.

Each time it runs I get CGI Timeout in the browser and a 502 error in the IIS log.

11:41:04 127.0.0.1 GET /CGI/ah1.cgi 502

I am able to run the database connection code in a stand alone script which works fine (even returns results) and the CGI script will run if the database connection code is comented out.

My code is below and all I want at the moment is for the database connection to suceed and display a simple page telling me so

#!C:\Perl\bin\perl.exe -wT use strict; use DBI; use CGI qw/:standard/; use CGI::Carp qw/fatalsToBrowser/; my $tainted_mpan = param( 'mpan' ) || ''; my $tainted_date = param( 'date' ) || ''; my $mpan = ''; my $dd=''; my $mm=''; my $yy=''; my $message = 'The MPAN you have entered is not valid. Please re-enter +'; my $message1="Invalid MPAN"; my $message2="Invalid Date"; #check that the mpan is in the correct format #it may not exist but it has to be 13 numbers if ( $tainted_mpan =~ /^(\d{13})$/ ) { $mpan = $1; #display_page($message2); }else{ display_page( $message1 ); exit; } #check that the date format is correct DD/MM/YY if ( $tainted_date =~ /^(\d{2})\/(\d{2})\/(\d{2})/) { $dd=$1; $mm=$2; $yy=$3; search_mpan(); }else{ display_page($message2); exit; } #routine to display any messages generated sub display_page { my $message = shift; print header, start_html, p( $message ), end_html; } sub search_mpan { my @rows; my $dbh = DBI->connect('dbi:ODBC:database.server',"username", "pas +sword") or display_page("$DBI::errstr"); display_page("This worked"); }

Thanks for any help regarding this.
howarda

In reply to CGI and DBI by howarda

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.