Home Ask Login Register

Developers Planet

Your answer is one click away!

vignesh warar February 2016

num_rows Always shows Zero value in PHP/MYSQL?

I am totally new to this 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.

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);
                        $numberofrows = $stmt->num_rows;
                        echo '<h1>'.$numberofrows.'</h1>';



Ashish Patel February 2016

Use () look like this... $numberofrows = $stmt->num_rows(); and try.

vignesh warar February 2016

Guys Thanx For your Ans Finally My friend helped me to solve this. We have to store the result before we calling num_rows


It works fine now

Post Status

Asked in February 2016
Viewed 2,572 times
Voted 12
Answered 2 times


Leave an answer

Quote of the day: live life