Re: Can't call method "Sql"... need help



On Feb 28, 4:13 pm, sud...@xxxxxxxxx wrote:
hello,

I have a problem CGI script. I am really sorry, this looks quite
big...

I created a package pkg::fetch_history.pm and placed it in c:\Perl
\lib. Then I created a perl file to run from the commad promt. the
program executed well without fail. The code is as follows,

#!C:\Perl\bin\perl.exe
use pkg::fetch_history;

@dates = pkg::fetch_history::get_Dates();
foreach $d (@dates)
{ print "\n",$d; }

the data base exists locally.

Then I created cgi script to populate the values into combo box, it
says

Can't call method "Sql" on an undefined value at C:/Perl/lib/pkg/
fetch_history.pm line 20.

I am not sure why is this. Below is the fetch_history.pm and
combobox.cgi script.

-----------------------------------------------------------------------------------------------
#!C:\Perl\bin\perl.exe

# this is fetch_history.pm

package pkg::fetch_history;
use strict;
use Win32::ODBC;

my $db = new Win32::ODBC('ServerStatistics'); #ODBC driver object
#if (!$db)
#{
# print "Database could not be found\n";
#}

sub get_Dates
{
my $q = "select distinct(build_date) from wdf_history order by
build_date";
$db->Sql($q);
my @dates;
push(@dates, $db->Data()) while($db->FetchRow);

return @dates;}

---------------------------------------------------------------------
#!C:\Perl\bin\perl.exe

use CGI::Carp qw(fatalsToBrowser);
use CGI;
use pkg::fetch_history;

$cgi = new CGI;
print $cgi->header;

@dates = pkg::fetch_history::get_Dates();
print "here is the dates value",@dates;
print <<ENDHTML;
<html>
<head><title> Server statistics </title></head>
<body>
<select name="menu">
ENDHTML

foreach my $d(@datest)
{
print <<ENDHTML;
<option value="$d" selected>(please select:)</option>
<option value="$d">$d</option>
ENDHTML

}
------------------------------------------------------------------

Am I wrong some where?

Thank you,
Regards,
kath.


If this script runs fine from command prompt, ..... then I think you
should check with permission.
I see that you are not catching error at the time of opening
connection to database.
While executing script from web, it executes with lower permission,
and it may not be allowed to connect to database.

Try catching error at the time of opening connection to database...


.



Relevant Pages

  • Re: Key-passing from PHP to TCL CGI script - how is it done (web security issue)?
    ... TCL v.8.3 ... set hasEnteredTrivia 0 ... # NEW 8/7/2004 USE PHP (AS CGI) TO CHECK IF USER IS ATTEMPTING TO ENTER ... # USE REMOTE PHP SCRIPT TO CHECK FOR REPOSTING ...
    (comp.lang.tcl)
  • DBI connect(db_local,,...) failed: at...
    ... able to obtain a connection to SQL Server -- or MS ... Access for that matter -- via cgi. ... The script works fine from the comman prompt, ... (note that there is no password associated with the DNS or database) ...
    (perl.dbi.users)
  • Re: Changing Passwords through the web (fwd)
    ... I use a CGI script that uses the poppassd and python ports on my small ... alert; ...
    (FreeBSD-Security)
  • Re: Help with a stragegy for diagnosis
    ... I have a Perl CGI that has work for years. ... first failure and before the second. ... A strategy would be to write tests for the script until you get the same ...
    (comp.lang.perl.moderated)
  • Re: Thomas The Tank
    ... We've just started to let our son watch the Simpsons but are very ... CGI appear to depend more on dancing images ... then am even more impressed by Star Wars, some films would have depended on those expensive effects and left it at that, but these have a good script as well. ... If you want to watch films with no CGI, good effects and wonderful scripts then I would recommend Wallace and Gromit. ...
    (uk.rec.models.rail)