I am a newbie so please forgive my question that might seem simplistic. I have created a CGI script that connects to an Oracle database. When I run the script from the c prompt everything is a success. I create the database and plot it. However when I try to submit the html form that calls the script, it fails. If I comment out the section in which the script talks to the database, everything works. Here is part of the code:
my $q = new CGI; my($surname, $givenName); $ENV{REMOTE_USER} = $q->param('Login_Name'); my $room = $q->param('Room'); my $sth; my $table = SQL->new(); my $dbh= DBI->connect("dbi:Oracle:", "scott", "tiger") or die $DBI::er +rstr; if (!($dbh->selectrow_array("select * from user_tables where table_nam +e = '$table->{name}'"))){ $sth= $dbh->prepare($table->create) or die $dbh->errstr; $sth->execute or die $sth->errstr; } $sth = $dbh->prepare(q/INSERT INTO SignIn(cn, time, cdate, room) VALUE +S (?,?,?,?)/) or die $dbh->errstr; $sth->execute($ENV{REMOTE_USER}, $foo, $foo, $room); print <<ENDOFHTML $ENV{REMOTE_USER}, $time, $date, $room Content-type:text/html\n\n <html> <body> <SCRIPT language="JavaScript"> alert("$givenName $surname you have signed in successfully on $fullDat +e. Thank you and enjoy Computers 101.") </SCRIPT> </body> </html> ENDOFHTML
Here is the module that I created
package SQL; sub new{ my $self = {}; $self->{name}='SIGNIN'; bless $self; return $self; } sub create{ my $self = shift; $self->{create} = "create table SignIn (cn varchar2(64), time varc +har2(10), cdate varchar2(20), room varchar2(20))"; return $self->{create}; } sub index{ my $self = shift; $self->{index} = "create index CNIndex on self->{name}(cn)"; return $self->{index}; } 1;
Thanks for any help

In reply to connect to Oracle through CGI by Anonymous Monk

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.