Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

DBI script works on command line but not in browser

by Anonymous Monk
on Jun 06, 2000 at 02:27 UTC ( #16511=perlquestion: print w/ replies, xml ) Need Help??
Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

My DBI script works correctly when run by a web server, but I get syntax errors when running it from the command line (Perl 5 and FreeBSD server). Here's the code:
use DBI; ($db) = DBI->connect('DBI:mysql:DatabaseName, $dbusername);
Here are the corresponding errors:
syntax error in file MyScript.cgi at line 66, next 2 tokens "use DBI" syntax error in file MyScript.cgi at line 82, next 2 tokens "->"
What's the problem?

Comment on DBI script works on command line but not in browser
Select or Download Code
Re: script using DBI won't run from command line but runs great thru browser. why?
by btrott (Parson) on Jun 06, 2000 at 03:02 UTC
    Sounds like you're running it w/ perl4 under the command line. How are you executing the file? Where's your perl? Do you have 2 versions installed?
Re: script using DBI won't run from command line but runs great thru browser. why?
by IndyZ (Friar) on Jun 06, 2000 at 05:22 UTC
    If I follow btrott correctly, you probanly have perl installed in two places, like perl4 in /bin/perl, and perl5 in /usr/bin/perl. try typing "whereis perl" and see where the binaries are.

    =Brian

Re: DBI script works on command line but not in browser
by Zombie codehopper (Initiate) on Mar 07, 2003 at 18:10 UTC
    use DBI;
    my $dbh = DBI->connect("DBI:mysql:databasename:server", "user","password")
        or die "Couldn't connect to database";

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (7)
As of 2014-08-29 19:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (287 votes), past polls