|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
All,
Firstly, this is my first post to this group, so thanks in advance. I have searched the archive for an answer with success. I am trying to connect to a MySQL database from Perl, Everything works fine when I run the script locally, but as soon as I try and run the script through a server I get the follow error message: - Can't create IP socket (10106) From the DBI module. I can guess at what it means, but have no idea how to resolve it. Any help would be greatly appreciated. Cheers, Matt. |
|
#2
|
|||
|
|||
|
Hi
The basic script I use is as follows :- #!/usr/bin/perl use DBI; $db = "test"; $sock = "/tmp/mysql.sock"; $user = "user"; $pass = "password"; $dsn = "DBI:mysql:$db;mysql_socket=$sock"; $dbh = DBI->connect($dsn,$user,$pass); $sth = $dbh->prepare("SELECT * FROM Test"); $sth->execute(); while (my $ref = $sth->fetchrow_hashref()) { print "ID = $ref->{'ID'}, Name = $ref->{'Name'}n"; } $sth->finish(); $dbh->disconnect(); ########### I tend to connect via the unix socket rather then an IP address style connection (Only works locally) Regards Darren http://www.php4hosting.com/ $ http://www.php4hosting.co.uk/ £ |
![]() |
| Viewing: Dev Shed Forums > Databases > MySQL Help > Accessing a MySQL database from Perl |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|