I have made this example code:
$db = new mysqli("localhost","root","password","xxx");
$statement = $db->prepare("SELECT name, password FROM persons WHERE name=? LIMIT 1");
$statement->bind_param('s', "kevin");
$statement->execute();
if($statement->num_rows){
$statement->bind_result($dbname, $dbpassword);
$statement->free_result();
};
echo $dbname;
echo $dbpass;
How can use/get $dbname and $dbpassword directly without using something like:
while($statement->fetch()){
echo $dbname;
}
I want to use $dbname and dbpassword directly. What is the best approach? What am I doing wrong.