Created
April 4, 2013 12:25
-
-
Save alfredbez/5309941 to your computer and use it in GitHub Desktop.
PHP: Create Mysql Connection
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<snippet> | |
<content><![CDATA[ | |
/********************************/ | |
/* MySQL Connection */ | |
/********************************/ | |
if( $_SERVER['REMOTE_ADDR'] != '127.0.0.1' ){ | |
$mysqlhost="${1:localhost}"; | |
$mysqluser="${2:user_remote}"; | |
$mysqlpwd="${3:password_remote}"; | |
$mysqldb="${4:db_name_remote}"; | |
} | |
else{ | |
$mysqlhost="${5:localhost}"; | |
$mysqluser="${6:user_local}"; | |
$mysqlpwd="${7:password_local}"; | |
$mysqldb="${8:db_name_local}"; | |
} | |
$connection = mysql_connect($mysqlhost, $mysqluser, $mysqlpwd) | |
or die ("Verbindungsversuch fehlgeschlagen"); | |
mysql_select_db($mysqldb, $connection) | |
or die("Konnte die Datenbank nicht waehlen."); | |
mysql_query("SET NAMES utf8"); | |
]]></content> | |
<tabTrigger>mysql_connection</tabTrigger> | |
<scope>source.php</scope> | |
</snippet> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment