Last active
December 18, 2018 07:13
-
-
Save dkarandana/82dc6ac7052c5492517d4be1808bad62 to your computer and use it in GitHub Desktop.
PHP MySQL Connection
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 | |
defined('DB_SERVER') ? null : define("DB_SERVER", "localhost"); | |
defined('DB_USER') ? null : define("DB_USER", "******"); | |
defined('DB_PASS') ? null : define("DB_PASS", "******"); | |
defined('DB_NAME') ? null : define("DB_NAME", "IMDBTop100"); | |
$mysqli = mysqli_connect( DB_SERVER, DB_USER, DB_PASS, DB_NAME); | |
if ( !$mysqli ) { | |
$connection = "Error: Unable to connect to MySQL." . PHP_EOL; | |
$connection .= "Debugging errno: " . mysqli_connect_errno() . PHP_EOL; | |
$connection .= "Debugging error: " . mysqli_connect_error() . PHP_EOL; | |
exit( $connection ); | |
}else{ | |
$connection = "Connection success - Host information: " . mysqli_get_host_info( $mysqli ); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment