note 71046 added to function.mysql-connect
| From: | brinca at substancia dot com | Date: | Thu, 09 Nov 2006 15:43:53 +0000 |
| Subject: | note 71046 added to function.mysql-connect | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-119559@lists.php.net to get a copy of this message | ||
If you prefer to use a hostname instead of an ip on your connection string in a script (to be able
to change the ip at will), but don't want the overhead of dns lookups, just add it to your
/etc/hosts file (in windows: %WINDIR%/system32/drivers/etc/hosts).
For example, add the following to your hosts file (changing the bogus ip to your server's real
ip):
123.123.123.123 mysqlserver1
Note: On linux, make sure you have "order: hosts,bind" on your /etc/host.conf file.
On a script, make the mysql connection like so:
<?
$sid = mysql_connect ("mysqlserver1", "user", "pass");
?>
Note: this sample is in php, but it can be any other programming language (just type "ping
mysqlserver1" on a prompt, on your server)
And there you have it! If your server ever gets assigned a different ip, just update the hosts file
with the new one (every script will work as-is, even if under different hostnames).
----
Server IP: 81.92.200.26
Probable Submitter: 82.154.198.252
----
Manual Page -- http://www.php.net/manual/en/function.mysql-connect.php
Edit -- https://master.php.net/note/edit/71046
Del: integrated -- https://master.php.net/note/delete/71046/integrated
Del: useless -- https://master.php.net/note/delete/71046/useless
Del: bad code -- https://master.php.net/note/delete/71046/bad+code
Del: spam -- https://master.php.net/note/delete/71046/spam
Del: non-english -- https://master.php.net/note/delete/71046/non-english
Del: in docs -- https://master.php.net/note/delete/71046/in+docs
Del: other reasons-- https://master.php.net/note/delete/71046
Reject -- https://master.php.net/note/reject/71046
Search -- https://master.php.net/manage/user-notes.php