note 104876 deleted from function.mysql-connect by thiago

From: Date: Wed, 13 Jul 2011 17:00:03 +0000
Subject: note 104876 deleted from function.mysql-connect by thiago
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-181471@lists.php.net to get a copy of this message
Note Submitter: hungry dot mind at hotmail dot com ---- Code: One MySQL Database Connection Is Handling 3 Process. 1st for Local PC, 2nd for Local Network PC using It's IP Series, 3rd for Hosting Server. You Can Make It One Time Database Connection For Multipurpose. <?php // Setting IP's define("USER_IP", $_SERVER['REMOTE_ADDR']); define("LOCAL_IP", '127.0.0.1'); // Local System IP $IP_Series = '192.168.1.'; // Local Network IP Series for ($i=0; $i<256; $i++) { $set_IP = $IP_Series . $i; if (USER_IP == $set_IP) { define("LOCAL_NETWORK_IP", $set_IP); // Finding Local Network System IP } } define("HOSTING_SERVER_IP", ''); // Hosting Server IP, Not Necessary, It Will Work On Default switch (USER_IP) { case LOCAL_IP: // Setting Local Computer IP define("LOCALHOST", "localhost"); define("USERNAME", "root"); define("PASSWORD", ""); define("DATABASE", "database"); break; case LOCAL_NETWORK_IP: // Setting Local Network System IP define("LOCALHOST", "localhost"); define("USERNAME", "root"); define("PASSWORD", ""); define("DATABASE", "database"); break; default: // Setting Hosting Server IP define("LOCALHOST", "localhost"); define("USERNAME", "root"); define("PASSWORD", ""); define("DATABASE", "database"); } // Database Connection (!$db = mysql_connect(LOCALHOST, USERNAME, PASSWORD)) ? die('DB Connection Error: ' . mysql_error()) : (!mysql_select_db(DATABASE, $db)) ? die('DB Selection Error: ' . mysql_error()) : ''; ?>

« previous php.notes (#181471) next »