[英]num_rows Always shows Zero value in PHP/MYSQL?
I am totally new to this PHP. 我对这个PHP完全陌生。
I am just practicing Prepared statements. 我只是在练习准备好的语句。 I know there few questions which is related to mine.
我知道很少有与我有关的问题。
But nothing Helped me. 但是没有任何帮助。
This is my php code Which returns always num_rows
equal to Zero. 这是我的php代码,该代码始终返回
num_rows
等于零。
But there is a data in my table 但是我的桌子上有数据
if (isset($_POST['submit'])) {
$my_id = 49;
$content = $_POST['cont'];
$content_date = date('d-m-y');
$check = "SELECT * FROM post WHERE user_id = ?";
$stmt = $con->prepare($check);
$stmt->bind_param("i",$my_id);
$stmt->execute();
$stmt->fetch();
$numberofrows = $stmt->num_rows;
$stmt->close();
echo '<h1>'.$numberofrows.'</h1>';
}
Use () look like this... $numberofrows = $stmt->num_rows(); 使用()看起来像这样... $ numberofrows = $ stmt-> num_rows(); and try.
并尝试。
Guys Thanx For your Ans Finally My friend helped me to solve this. 伙计们感谢您的回答最后,我的朋友帮助我解决了这个问题。 We have to store the result before we calling num_rows
我们必须在调用num_rows之前存储结果
$stmt->store_result();
It works fine now 现在工作正常
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.