Hi I was trying out some practice examples with DBI and CGI and kind of stuck while doing a comparison
That is if I could insert successfully into a databse a script window shld come "Success". but when the insert fails a window shld come saying "Can;t insert ".. How will I track if the insertion is success or not? Below is the program... use strict; use warnings; use CGI; use DBI; my $cgi = new CGI; print $cgi->header( "text/html" ); print $cgi->start_html( "Welcome" ); my $dbh = DBI->connect("DBI:Pg:dbname=testdb;host=localhost",'postgres','postgres',{RaiseError=>1,PrintErr or=>1}) or die "Cannot connect to testdb\n"; my $sth=$dbh->prepare("insert into userinfo values('$fvalue','$lvalue','$email')"); $sth->execute(); if($sth) { print $cgi->p( "<script language=Javascript> alert('Execution Done') </script>" ); } else { print $cgi->p("<Script language=Javascript> alert('Execution Not Done') </script>" ); }