Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
213 views
Welcome To Ask or Share your Answers For Others

1 Answer

This line:

$queryLink->store_result;

Should be a method call:

$queryLink->store_result();

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...