Re: Connecting to mysql from another host

From: Date: Fri, 03 Aug 2007 08:26:48 +0000
Subject: Re: Connecting to mysql from another host
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-43874@lists.php.net to get a copy of this message
Well you it depends on what method you use to access mysql. If for instance if you use PDO you could do something like that to connect and query: <?php $dbhost = 'remote_hostname'; $dbuser = 'mysql_username'; $dbpass = 'mypass'; $db = 'database_to_use'; $db_handler = new PDO('mysql:host='.$dbhost.';dbname='.$db, $dbuser, $dbpass); $query = "SELECT id, fname, lname FROM users WHERE id>'1'"; $st_handler = $db_handler->prepare($query); $st_handler->execute(); ?> Have in mind that you must have installed the PDO mysql modules using pear for this method to work. There are other methods like this one: http://www.php-mysql-tutorial.com/connect-to-mysql-using-php.php Have fun, Theodoros Goltsios Kinetix Tele.com Support Center email: tgol@kinetix.gr, support@kinetix.gr Tel. & Fax: +30 2310556134 WWW: http://www.kinetix.gr/ joefazee wrote:
I want to connect to a database hosted on another server like from www.sample.com i want to connect to www.example2.com.what did i need to do? Thanks.


« previous php.db (#43874) next »