Saturday, 14 September 2013

How to connect mysql db in another host using PDO?

How to connect mysql db in another host using PDO?

I don't know how connect into one mysql db in different host(server) to
show medicament list in another website... can you help me with this?
here is the connection I use in the same server, but in different server I
can't connect. Can you explain me how to do it?
<?php
$dbtype = "mysql";
$dbhost = "localhost";
$dbname = "XXXX_medicament";
$dbuser = "XXXX_medicament";
$dbpass = "123456789";
$conn = new PDO("mysql:host=$dbhost;dbname=$dbname",$dbuser,$dbpass);
$conn->exec("set names utf8");
$conn->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
?>

No comments:

Post a Comment