note 32266 deleted from function.mysql-connect by philip
| From: | philip@php.net | Date: | Mon, 02 Jun 2003 14:00:30 +0000 |
| Subject: | note 32266 deleted from function.mysql-connect by philip | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-49563@lists.php.net to get a copy of this message | ||
Note Submitter: bgw@globe.net.nz
----
When developing php/mysql on a local machine, then uploading to a remote site, here is a little tip
to speed development and testing when using mysql_connect. This will save you having to change
server info for the connect function.
Note: it assumes a secure development machine as mysql login is default here.
When final testing has passed then the surplus can be deleted and just the remote login details
used.
--------------------------------------
//This script checks if we are on the local development
//machine or scipt is sittiing on the remote server
// Check to see if we are on the local(development machine)
if (getenv ("REMOTE_ADDR") == "127.0.0.1"){
$server_addr = "localhost";
$database = "test";
$user = "root";
$pass = "";
}else{
$server_addr = "db.remoteaddress.com";
$database = "database_name";
$user = "db_user_name";
$pass = "db_password";
}
// Connecting, selecting database
$link = @mysql_connect($server_addr, $user, $pass )
or die("Could not connect to database.");
@mysql_select_db($database)
or die("Could not select database.");
// Regards, Brett