note 104283 deleted from function.mysql-connect by danbrown

From: Date: Sun, 05 Jun 2011 19:41:15 +0000
Subject: note 104283 deleted from function.mysql-connect by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-180287@lists.php.net to get a copy of this message
Note Submitter: bimal at sanjaal dot com ---- Portable connections: If you migrate your source code from one to different servers and you would like to avoid re-configuration on a new serve, user the $_SERVER['SERVER_NAME'] flag as: <?php switch($_SERVER['SERVER_NAME']) { case 'server1.domain.com': mysqlconnect('host1', 'user1', 'password1'); mysql_select_db('db1'); break; case 'server2.domain.com': mysqlconnect('host2', 'user2', 'password2'); mysql_select_db('db2'); break; } ?> This makes a conditional connection to mysql database. It automatically chooses the correct server according to the server name from where your script runs. Hopefully, you like this portable configuration.

« previous php.notes (#180287) next »