CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Advanced: DBI can not connect to Mysql: Edit Log



photores
Deleted

Mar 26, 2001, 6:08 AM


Views: 1368
DBI can not connect to Mysql

Hi, guys!
Please, help.
I write script that use DBI for connecting to Mysql, but I have error:
- "DBI->connect(mail_list:localhost:3306) failed: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (111) at /var/www/cgi-bin/test.pl line 15
Can't call method "prepare" on an undefined value at /var/www/cgi-bin/test.pl line 17. "-
I try change users access e.t.c., but without results.
Please HELP! :-)

###########################################
#!/usr/bin/perl
################################
use CGI qw(:standard);
use DBI;
use Parse;
my $tpl = new Parse;
use strict;
my $db = param('db');
my $query = param('query');

print "Content-type: text/html\n\n";

if($query) {

my $dbh = DBI->connect("DBI:mysql:$db:localhost:3306");

my $dbs = $dbh->prepare($query);
$dbs->execute;
my $err = $dbh->errstr;
if($err) {
$tpl->{'ERROR'} = "А вот и ошибочка случилась: $err";
$tpl->{'DB'} = $db;
}
}
File is attached.




(This post was edited by photores on Mar 26, 2001, 5:16 AM)


This post has not been edited


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives