Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

Re: Re: Re: Re: DBI::mysql fetch() without execute() PROBLEM

by peppiv (Curate)
on Jan 22, 2002 at 20:47 UTC ( #140683=note: print w/replies, xml ) Need Help??

in reply to Re: Re: Re: DBI::mysql fetch() without execute() PROBLEM
in thread DBI::mysql fetch() without execute() PROBLEM

Thanks for the catch. I actually had it that way once, but since I couldn't get it to work I dropped it.

#!/usr/bin/perl -w use strict; use DBI; use CGI::Carp qw(fatalsToBrowser); use CGI qw (:standard); print "Content-type: text/html\n\n"; my $dbh = DBI->connect(qq{DBI:mysql:database=subscriptions;host=l +ocalhost,I DON'T HAVE A USERNAME AND PASSWORD OTHER THAN ROOT}, {Rais +eError => 1} ); my $sth = $dbh->prepare( q{SELECT email FROM contacts WHERE state + = ?} ); $sth->execute('OH') or die $sth->errstr; while (my @result = $sth->fetchrow_array()) { print "@result\n"; } # check for problems which may have terminated the fetch early die $sth->errstr if $sth->err; $dbh->disconnect;

I've tried many things to connect but to no avail. \s tells me that I'm connected via a UNIX socket. I can only find docs about different ports. Could this be a problem?

Can't call method "prepare" on an undefined value at /usr/local/etc/ht +tpd/cgi-bin/ line 12.

Is there any way to view the path or connection?

Replies are listed 'Best First'.
Re: Re: Re: Re: Re: DBI::mysql fetch() without execute() PROBLEM
by cfreak (Chaplain) on Jan 23, 2002 at 00:32 UTC
    even if you don't have a password you should still put in the username. I'm not sure what you mean by \s. You should also make sure your mysql database is running. (i.e. Can you connect to it using the mysql client?).
      Things I've learned.

      \s is the command you type in when you're in the mysql client. It tells you lots of cool information. Who you're logged in as, your connection, etc. Very neat.

      Also, I've learned to run "top" in Telnet. It tells me all the processes running. Including the mysqld.
        That's cool I'll have to check that out, I didn't know about it. And yes 'top' is a very useful tool. 'ps aux' also gives good information on running processes.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2021-06-14 21:39 GMT
Find Nodes?
    Voting Booth?
    What does the "s" stand for in "perls"? (Whence perls)

    Results (66 votes). Check out past polls.