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

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

am 20.10.2007 19:23:28 von 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 <




ICOLT--

CHECKNAME:



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:
";
print "severity: $severity
";
print "error: $error
";
print "database: $db
";
print "message: $error_msg
";
print "os error msg: $os_error_msg
";
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:
";
print "database: $db
";
print "message: $message
";
print "text: $text
";
print "server: $server
";
print "line no: $line
n";
0;
}

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

am 20.10.2007 22:37:52 von 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