Skip to content

Instantly share code, notes, and snippets.

@yyoshiki41
Created November 20, 2014 09:03
Show Gist options
  • Save yyoshiki41/05460d67bce028aa838e to your computer and use it in GitHub Desktop.
Save yyoshiki41/05460d67bce028aa838e to your computer and use it in GitHub Desktop.
<?php
// Create connection
$mysqli = new mysqli('HOST', 'USER', 'PW');
// Check connection
if ($mysqli->connect_errno) {
printf("Connect failed: %s\n", $mysqli->connect_error);
exit();
}
// Check DB server
if ($mysqli->ping()) {
printf ("Our connection is ok!\n");
} else {
printf ("Error: %s\n", $mysqli->error);
}
// Close connection
$mysqli->close();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment