[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [cgiapp] Using DBI in CGI::Application


Le 21 mai 04, à 17:28, Geoffrey G. Hankerson a écrit :

package Course_manager;
use base 'CGI::Application';
use DBI;
use strict;
use warnings;

sub setup{
    my $self = shift;
    $self->run_modes(
	'mode_1'=>'add_instructor',
	'mode_2'=>'add_course',
	'mode_3'=>'edit_instructor',
	'mode_4'=>'edit_exam',
	'mode_5'=>'update_course'
    );
    $self->start_mode('mode_1');
    $self->mode_param('rm');
    }

sub teardown{
    my $self = shift;
    #my $dbh = $self->param('dbh');
    #$dbh->disconnect();
}

sub add_instructor{
    my $self = shift;
    my $sql;
    my $dbh;
    my $sth;
    my $output;
    $dbh =
DBI->connect('dbi:SQLite:/Library/Webserver/CGI-Executables/cgiDev/ dbitest/exams.db')
or die "Error: " . $DBI::errstr;
    $sql = "INSERT INTO profs (profName) VALUES ('Prof BBB')";
    #$sql = "SELECT * FROM profs";
    $sth = $dbh->prepare($sql);
    $sth->execute();
    $output = "text";
    return $output;
}

Apache error log returns this error:
courseApp.pl: Use of uninitialized value in subroutine entry at
Course_manager.pm line 37.
courseApp.pl: DBD::SQLite::st execute failed: at Course_manager.pm line
37.

Suggestions are appreciated.

Apache must have Read-Write access to the SQLite file DB :
$ chmod 666 /Library/Webserver/CGI-Executables/cgiDev/dbitest/exams.db


JMP
--
http://www.suricate.net/


---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/suppressed/
             http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: suppressed
For additional commands, e-mail: suppressed


Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.