kalaisuresh has asked for the wisdom of the Perl Monks concerning the following question:

hai,

in my program i used the DBI module

my program running well in terminal(redhat linux 9.0)

if i use the same program in interface (use CGI) that time it shows the log error

[Mon Nov 27 20:29:35 2006] [error] [client] BEGIN failed--compilation +aborted at /home/httpd/cgi-bin/mysql_kalai/selectPdb.pl line 9. [Mon Nov 27 20:29:43 2006] [error] [client] Premature end of script he +aders: selectPdb.pl [Mon Nov 27 20:29:50 2006] [error] [client ] Premature end of script h +eaders: selectPdb.pl [Mon Nov 27 20:29:50 2006] [error] [client ] Can't locate Exporter/Hea +vy.pm in @INC (@INC contains: /usr/lib/perl5/5.8.0/i386-linux-thread- +multi /usr/lib/perl5/5.8.0 /usr/lib/perl5/site_perl/5.8.0/i386-linux- +thread-multi /usr/lib/perl5/site_perl/5.8.0 /usr/lib/perl5/site_perl +/usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi /usr/lib/per +l5/vendor_perl/5.8.0 /usr/lib/perl5/vendor_perl /usr/lib/perl5/5.8.0/ +i386-linux-thread-multi /usr/lib/perl5/5.8.0 .) at /usr/lib/perl5/5.8 +.0/Exporter.pm line 17. [Mon Nov 27 20:29:50 2006] [error] [client] BEGIN failed--compilation +aborted at /usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi/D +BI.pm line 250. [Mon Nov 27 20:29:50 2006] [error] [client ] Compilation failed in req +uire at /home/httpd/cgi-bin/mysql_kalai/selectPdb.pl line 9. [Mon Nov 27 20:29:50 2006] [error] [client] BEGIN failed--compilation +aborted at /home/httpd/cgi-bin/mysql_kalai/selectPdb.pl line 9.

still i dont know what is the problem here.but the program works fine in terminal

here with i send a progam..
please help

#!/usr/bin/perl -w print "content-type:text/html\n\n"; print "<html>"; print "<head>"; print "<body>"; use CGI; $cgi=new CGI; #BEGIN { $ENV{DBI_PUREPERL} = 1 } use DBI; #::PurePerl; $pdb=$cgi->param('pdb'); $dbh=DBI->connect('dbi:mysql:mysql','kalai','kavithai') or die "connec +tion failed : $DBI::errstr"; $pdb="1une"; $query="select * from pdbsummary where pdbid='$pdb'"; $exe=$dbh->prepare($query); $exe->execute(); while(@array=$exe->fetchrow_array()) { print @array; } $exe->finish; $dbh->disconnect; print "</body>"; print "</html>"; plz help me

20061127 Janitored by Corion: Added formatting, code tags, as per Writeup Formatting Tips

Replies are listed 'Best First'.
Re: error in perl with mysql
by shmem (Chancellor) on Nov 27, 2006 at 15:45 UTC
    Is your web server running in a chroot(1) environment?

    If so, check if you find the file

    usr/lib/perl5/5.8.0/Exporter/Heavy.pm

    relative to the web server's root directory, and check its permissions.

    --shmem

    _($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                                  /\_¯/(q    /
    ----------------------------  \__(m.====·.(_("always off the crowd"))."·
    ");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
      hai, Heavy.pm is in the same path only and also i have /home/httpd/cgi-bin/perl2exe/perl5/lib/5.6.1/Exporter/ i check the permission also that is 755.
        Run the following as CGI
        #!/usr/bin/perl -T use strict; use CGI; my $q = CGI->new; print $q->header, $q->start_html; eval "use DBI"; if ($@) { my $err = $@; print $q->h2("Errors from <i>use DBI</i>:"); print "<pre>\n$err\n</pre>\n"; print $q->h2("%INC:"); print "<pre>\n"; print "$_ => $INC{$_}\n" for sort keys %INC; print "</pre>\n"; } else { print "DBI loaded OK.\n"; } print $q->end_html;
        and examine it for the location of Exporter.pm. Make sure it's anchored in the right path.

        --shmem

        _($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                                      /\_¯/(q    /
        ----------------------------  \__(m.====·.(_("always off the crowd"))."·
        ");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
Re: error in perl with mysql
by themage (Friar) on Nov 27, 2006 at 15:54 UTC
    Hi kalaisuresh,

    Are you running the script in terminal and as cgi in the same system? If not, did you installed DBI using CPAN or your package system, or did you copy some perl modules that you needed, as DBI (by ftp, for instance)?

    Did you verify that your @INC have the same values in the terminal and when runned as cgi?

    Try this script, run it in the terminal and as a cgi and compare the output from both runs:
    #!/usr/bin/perl use strict; print "Content-type: text/plain\n\n"; print join "\n", @INC,"\n";
    Hope this help you find your problem.

      hai i rubn this program in both terminal and websrever i got the result in terminal ----------------------------- Perl version: 5.008 + INC: /usr/lib/perl5/5.8.0/i386-linux-thread-multi /usr/lib/perl5/5.8.0 /usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.0 /usr/lib/perl5/site_perl /usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.0 /usr/lib/perl5/vendor_perl /usr/lib/perl5/5.8.0/i386-linux-thread-multi /usr/lib/perl5/5.8.0 . in browser ---------- Perl version: 5.008 INC: /usr/lib/perl5/5.8.0/i386-linux-thread-multi /usr/lib/perl5/5.8.0 /usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.0 /usr/lib/perl5/site_perl /usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.0 /usr/lib/perl5/vendor_perl /usr/lib/perl5/5.8.0/i386-linux-thread-multi /usr/lib/perl5/5.8.0 .
Re: error in perl with mysql
by olus (Curate) on Nov 27, 2006 at 16:02 UTC
    1. Don't know where the dependency comes from, but from the log you are missing the module Exporter::Heavy.
    2. Declare your variables
    3. use $dbh->quote($pdb) instead of '$pdb' in the sql statement
    4. check for errors when preparing and executing the query

    -----
    olus
      use $dbh->quote($pdb) instead of '$pdb' in the sql statement

      Or, even better, use placeholders and an extra parameter to execute.

      $query = 'select * from pdbsummary where pdbid=?'; $exe = $dbh->prepare($query); $exe->execute($pdb);
      --
      <http://dave.org.uk>

      "The first rule of Perl club is you do not talk about Perl club."
      -- Chip Salzenberg

Re: error in perl with mysql
by BrowserUk (Patriarch) on Nov 27, 2006 at 15:32 UTC

    Update: Ah, I see the (now) OP, and this post got moved from the bowels of that other thread. My thanks to the on-the-ball editors.

    plz help me

    Sorry, I have no idea.

    However, if you post this as a separate question, rather than as a reply to a reply to a completely unrelated question, you might well find that one of the many web work gurus here will be able to help you.

    Especially if you read and comply with the Writeup Formatting Tips before you post your question.


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.