Page 1 of 1

connect external database pdo

Posted: Wed Jan 23, 2013 10:15 pm
by uloloi
Hi, is it possible to connect another external database using pdo? Something like this:

Code: Select all

try {
    $dbh = new PDO('mysql:host=localhost;dbname=mydb', $user, $pass);
    $dbh->exec("SET CHARACTER SET utf8");
    $dbh = null;
} catch (PDOException $e) {
    print "Error!: " . $e->getMessage() . "<br/>";
    die();
}
How can I connect the database? I don't know :(

I'm trying to make an autocomplete field, so I need to bring data as json encoding from another database