Last active
December 27, 2015 11:29
-
-
Save N-Porsh/7318827 to your computer and use it in GitHub Desktop.
PHP: MySQLi connection template
This file contains 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
<?php | |
/* CONFIG */ | |
define("DB_HOST", "localhost"); | |
define("DB_USER", "root"); | |
define("DB_PASS", ""); | |
define("DB_DATABASE", "my_db"); | |
/* CONNECTION */ | |
$link = @mysqli_connect(DB_HOST, DB_USER, DB_PASS, DB_DATABASE); | |
if (!$link) { | |
die('Connect Error (' . mysqli_connect_errno() . ') ' | |
. mysqli_connect_error()); | |
} | |
/* change character set to utf8 */ | |
if (!mysqli_set_charset($link, "utf8")) | |
printf("Error loading character set utf8: %s\n", mysqli_error($link)); | |
/* CLOSE CONNECTION */ | |
mysqli_close($link); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment