Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

error with CGI program: Can't locate object method "connect" via package "DBI"

by wayko (Initiate)
on May 07, 2002 at 13:16 UTC ( #164627=perlquestion: print w/ replies, xml ) Need Help??
wayko has asked for the wisdom of the Perl Monks concerning the following question:

i have a code it is written like this
#!/usr/bin/perl $first = $field{'first'}; $last = $field{'last'}; $address = $field{'address'}; $email = $field{'email'}; $phone = $field{'phone'}; $user = $field{'user'}; $pass = $field{'pass'}; use DBI; $dbh = DBI->connect("dbi:ODBC:'driver = Driver do Microsoft Access(*.m +db); dbq=test.mdb'"); print"<html><body><h1>this is a test</h1>"; $sql = qq{INSERT INTO Dreamcpu(FirstName, LastName, Address, Email, Ph +one, Username, Password) VALUES ('$first', '$last', '$adress', '$emai +l','$phone', '$user', '$pass');}; $rc = $dbh->do($sql); print"$rc record(s) were added.<p>"; $sth = $dbh->prepare("SELECT ID,FirstName,LastName,Address,Email,Phone +,Username,Password FROM Dreamcpu"); $sth->executive(); print"<table>\n"; print"<tr> <th>ID</th> <th>First</th> <th>Last</th> <th>Address</th> < +th>Email</th> <th>Phone</th> <th>User</th> <th>Password</th>\n"; while (@row = $sth->fetchrow_array) { print"<tr>"; foreach(@row) { print"<td>$_</td>"; } print"</tr>\n"; } print"</table>\n"; print"</body></html>"; $sth->finish; $dbh->disconnect;
when i goto the webpage i get the following error
CGI Error The specified CGI application misbehaved by not returning a complete s +et of HTTP headers. The headers it did return are: Can't locate object method "connect" via package "DBI" (perhaps you fo +rgot to load "DBI"?) at C:\Inetpub\wwwroot\cgi-bin\database1.pl line +12.

any ideas
i installed dbi

2002-05-07 kudra Changed title, added code tags
2003-02-20 jeffa added spaces to long lines
2005-10-14 jdporter moved to root node in SoPW; was originally posted as a reply to RE: Site How To. Also fixed (finished) the code tags.

Comment on error with CGI program: Can't locate object method "connect" via package "DBI"
Select or Download Code
Re: error with CGI program: Can't locate object method "connect" via package "DBI"
by DaWolf (Curate) on May 08, 2002 at 14:26 UTC
    First thing you should do is what I call "Simplification". Make a simpler script using DBI and see if it runs ok. Make a REALLY simple one, something like:
    • connect
    • select one field from a table
    • print the result
    By doing this you will know for sure if this is a code problem or an installation problem.

    This error message usually means you have a bad installation... How did you installed DBI?

    Best regards,

    my ($author_nickname, $author_email) = ("DaWolf","erabbott\@terra.com.br") if ($author_name eq "Er Galvão Abbott");

    P.S.: Are you from Brazil too? :-)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://164627]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2015-07-04 05:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (57 votes), past polls