Skip to content

Instantly share code, notes, and snippets.

@peterentwistle
Created October 29, 2014 09:46
Show Gist options
  • Save peterentwistle/d350b7ff408688833da4 to your computer and use it in GitHub Desktop.
Save peterentwistle/d350b7ff408688833da4 to your computer and use it in GitHub Desktop.
<?php
$dbCon = mysqli_connect("localhost", "root", "yourpasshere", "tutorials");
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
/* check if server is alive */
if (mysqli_ping($dbCon)) {
printf ("Our connection is ok!\n");
} else {
printf ("Error: %s\n", mysqli_error($link));
}
/* close connection */
mysqli_close($dbCon);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment