Bookmarks

Yahoo Gmail Google Facebook Delicious Twitter Reddit Stumpleupon Myspace Digg

Search queries

Www.xxxcon., %s wwwxxxcon, %s wwwxxxcon, www.xxxcon, xxxxdup, bitlord outgoing port settings, ckowwwxxx, 192.168.1.41:8000/nor-482.html, php.ini "Unable to initialize module", sendmail add footer to all messages

Links

XODOX
Impressum

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

Posted on 2007-10-20 19:23:28 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
{

@RegionData = $dbproc->sql("SELECT CheckName FROM CheckTb");
$NumRegions = @RegionData;
}

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

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

Posted on 2007-10-20 22:37:52 by Janwillem Borleffs

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

The first you should check is what's in your Apache error logs.

You might also want to start your scripts with the following line to get
more verbose error messages (in some cases):

use CGI::Carp qw(fatalsToBrowser);

Anyways, the error seems to be in the following snippet:

> sub Main {
>
> print "Content-type: text/html\n\n";
>
> &GetRegions;
> &display_menu;
>
> sub GetRegions
> {
>

The body of the Main sub routine isn't closed (missing closing curly
bracket).


JW

Report this message