Hello how should I make this work:
I am wondering why when I'm using a prepared statement it doesn't work. I tried using the query method and it works.
Here's what I've tried:
$query = new mysqli('localhost','root', '', 'sample');
$rows = $query->query('SELECT * FROM `sample`.`sample_user` WHERE `userName` = "test" AND `userPass` = "data"');
echo $rows->num_rows; // this returns 1 since I have this record from my database
I'm trying to enhanced it by using a prepared statement :
$query = new mysqli('localhost','root', '', 'sample');
$prepared = $query->prepare('SELECT * FROM `sample`.`sample_user` WHERE `userName` = ? AND `userPass` = ?');
$prepared->bind_param("ss", $userName, $userPass );
$prepared->execute();
echo $prepared->num_rows; //this returns 0
I'm stuck with this issue. Maybe there's something I missed.