Quantcast
Channel: PHP Freaks: PHP Help
Viewing all articles
Browse latest Browse all 13200

MySQLI query

$
0
0

Hey,
 
So recently I decided to try learn MySQLi but I can't find any in depth guides or tutorials so I'm pretty much trying things out for myself.
 
I'm having trouble with a simple query and I'm not sure why, it doesn't throw errors (even when I had an error in the query, I had to manually use $mysqli->error)
 
Here is the code: 

<?PHP
error_reporting(E_ALL);
$mysqli = new mysqli(); // removed data
 
if ($mysqli->connect_error) {
die('Connect Error (' . $mysqli->connect_errno . ') '
. $mysqli->connect_error);
}
 
 
$preparation = $mysqli->prepare("SELECT `username`,`password` FROM `users` WHERE `email` = ? ");
 
$username="test";
$preparation->bind_param('s', $username);
 
$Rusername = "";
$password = "";
 
 
$preparation->execute();
$preparation->bind_result($Rusername, $password);
while($preparation->fetch()) {
echo $Rusername . "<br>" . $password . "<br><br>";
}
$preparation->close();
?>

Question 2: Can I make it display any sort of error throughout any part of the code?


Viewing all articles
Browse latest Browse all 13200

Trending Articles