UK PHP MySql Website Hosting



Menu
 ·  Home
 ·  Open a Reseller Account
 ·  Domain Names
 ·  Web Hosting Accounts
 ·  Who-is
 ·  Our Price List
 ·  Help/FAQ
 ·  News
 ·  PHP Faq
 ·  PHP/MySQL Links
 ·  Contact Us
 ·  Terms and Conditions
 
 ·  Our Blog / Offsite News
 ·  Money Back Guarantee
 

Server Solutions
 
 ·  UK Colocation
 ·  Dedicated Servers
 


!! Domain Managment !!
 
 ·  Recover Password
 ·  Manage Global Domains
 ·  Manage UK Domains
 ·  Renew Domain
 



!! New Features !!
 
 ·  Free Webmail
 ·  E-Mail Anti Virus Scanning
 ·  MySQL4 Optional Support
 ·  Latest PHPMyAdmin
 ·  Free Multiple FTP Accounts
 ·  Free SpamAssassin Install
 

Join Mail List
 
 

php hosting MySQL hosting
Get Firefox!

php + Secure hosting (SSL)
 

Question :
How do I connect to Perl using MySQL?
Answer :
Assuming the following :-
* MySQL is installed
* You have your own instance (I.E. account larger than the smallest one)
* Username = fred
* Root password letmein
* Connecting to MySQL database "mysql"

#!/usr/bin/perl

use DBI;

$db = "mysql";
$sock = "/tmp/mysql.fred";
$user = "root";
$pass = "letmein";
$dsn = "DBI:mysql:$db;mysql_socket=$sock";

$dbh = DBI->connect($dsn,$user,$pass);
$sth = $dbh->prepare("SELECT * FROM users");
$sth->execute();
while ( my $ref = $sth->fetchrow_hashref() )
{
print "ID = $ref->{'ID'}, Name = $ref->{'Name'}\n";
}
$sth->finish();
$dbh->disconnect();

If you have the smallest account you just need to replace the $sock line as follows :-
$sock = "/tmp/mysql.sock";


Categories


 

Questions

MySQL
Does your firewall allow remote connections?
Can I backup MySQL?
Is MySQL installed by default?
 

Return to the main FAQ list


Registered Address: 20 Gartree Drive Melton Mowbray Leicestershire LE13 0AE
Company Number:
All prices exclude VAT charged at 17.5%

Email:

Copyright Information
Copyright © 2000-2010 . All Rights Reserved

PHP Hosting