Last active
December 6, 2017 20:51
-
-
Save sarkarshuvojit/c8169ac9afa3cfb4b733e6977d7a80e9 to your computer and use it in GitHub Desktop.
Blog demo code
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 | |
// connect to database | |
$con = mysqli_connect('host', 'user', 'password', 'db_name'); | |
// check for connection errors | |
if(mysqli_connect_errno()) | |
die(mysqli_connect_error()); | |
// function to execute query and automatically check for errors | |
function query($sql){ | |
$result = mysqli_query($GLOBALS['con'], $sql); | |
if(!$result){ | |
die(mysqli_error($GLOBALS['con'])); | |
} | |
return $result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment