Created
May 31, 2013 02:59
-
-
Save bittersweetryan/5682721 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<? | |
require_once '_header.php'; | |
$db = $sql -> OpenSafeConnection(); //see below | |
$sql = "SELECT firstname FROM jobapplications WHERE firstname = ?"; | |
$query = $db->prepare( $sql ); | |
$name = 'Nicole'; | |
$query->bind_param('s', $name); | |
$result = $query->execute(); | |
$query->bind_result( $firstname ); | |
while( $query->fetch() ){ | |
echo( $firsname . '<br>' ); | |
} | |
?> |
This file contains hidden or 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
function OpenSafeConnection(){ | |
$db = new mysqli($this->_VARS["host"], $this->_VARS["login"], $this->_VARS["pass"], $this->_VARS["db"]); | |
if($db->connect_errno > 0){ | |
die('Unable to connect to database [' . $db->connect_error . ']'); | |
} | |
return $db; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment