Bookmarks

Yahoo Gmail Google Facebook Delicious Twitter Reddit Stumpleupon Myspace Digg

Search queries

078274121, info0a ip, should prodicers of software_based services be held liable or not liable for economic injuries, should producers of soft ware based services such as ATMs be held liable for economic injuries suffered when their systems fail?, nisc wwwxxx, wwwxxx0cm, should producers of software-based services, such as atms, be held liable for economic injuries suffered when their systems fail?, wwwxxx0cm, www.webdp.net, Event 9 IIS log failed to write entry

Links

XODOX
Impressum

#1: cgi script to connect to database and diaplay data in HTML throwing error

Posted on 2007-10-20 19:22:55 by nitikamehta23

I am new to cgi and have a query about same...
I wan to connect to database and display soem data in HTMl format.
Below is the code which i have wriiten.
DbSettings.Pets contains database information like username,pswd,Db
name.

When i run this cgi using " http://www.web.com/TEST/cgi-bin-kerb/test.cgi"
it displays " Page cannot be displayed"

Can somebody help e out with this?

Thanks,

#!/opt/bin/perl5.004
#*************************
#******* Trecs.cgi *****
#*************************
#$Log

require "DbSettings.Pets";

Sybase::DBlib::dberrhandle('error_handler');
Sybase::DBlib::dbmsghandle('message_handler');

use CGI;

$query = new CGI;

&Main ();

$dbproc->dbclose();

sub Main {

print "Content-type: text/html\n\n";

&GetRegions;
&display_menu;

sub GetRegions
{
#print "SELECT distinct Region FROM ACCOUNTS ORDER BY Region";
@RegionData = $dbproc->sql("SELECT CheckName FROM CheckTb");
$NumRegions = @RegionData;
#print "Number of Rgions:$NumRegions";
}

sub display_menu {
print <<EOF;
<HTML>
<HEAD>


<TABLE>
<TR><TD><FONT COLOR="BLUE"><B>ICOLT<TD>--</B>
<TD>
CHECKNAME:
<TD><SELECT NAME=CHECKNAME>
EOF
foreach $Region (@RegionData)
{
print "<OPTION>$$Region[0]";
}
print <<EOF;
</SELECT>

</TABLE>
EOF

} #Main

#*********************************************************** **************************
#******************** error handler
***********************************************
#*********************************************************** **************************


sub error_handler
{

print "Content-type: text/html\n\n";

my ($db, $severity, $error, $os_error, $error_msg,
$os_error_msg) = @_;

# Check the error code to see if we should report this.
# Traps operating system level errors; much more severe than
sql related errors
# Add whatever code necessary to handle the error properly

print "Error detected:<BR>";
print "severity: $severity<BR>";
print "error: $error<BR>";
print "database: $db<BR>";
print "message: $error_msg<BR>";
print "os error msg: $os_error_msg<BR>";
INT_CANCEL;
}

sub message_handler
{
print "Content-type: text/html\n\n";

my ($db, $message, $state, $severity, $text, $server,
$procedure, $line) = @_;
# Used to trap Sybase messages generated in cases like trying
to
# insert a row that violates an index. Currently we don't do
anything,
# add whatever code necessary to handle the message properly

print "Message detected:<BR>";
print "database: $db<BR>";
print "message: $message<BR>";
print "text: $text<BR>";
print "server: $server<BR>";
print "line no: $line<BR>n";
0;
}

Report this message