Can not figure out why this is not working. Have gone through other questions here, but it seems my code is fine.
$queryLink = $mysqli->prepare("SELECT vendor_name FROM vendors WHERE vendor_id='1'");
$queryLink->execute();
$queryLink->store_result;
$queryLink->bind_result($vendor_name);
$queryLink->fetch();
$numRows = $queryLink->num_rows;
$queryLink->close();
echo $vendor_name.'<br>'.$numRows;
The script returns this:
VendorNameHere
0
It is returning 1 record, but $numRows always stays 0. I have tried moving the numRows line to different places in the script, but it always returns 0. What am I doing wrong?
But you don't need number of rows here. Apparently there will be only one vendor with such id. Why bloat your code with useless function calls?
is all the code you need.
This line:
Should be a method call: