0

I am using GoDaddy shared hosting plan and looks like there are some issues on using the mysqli and mysqlnd in all versions of PHP 7,7.1,7.2, and 7.3 on their hosting.

After many tries on changing and updating PHP versions and modules I, eventually, gave up using the get_result() function as I am getting this error

Uncaught Error: Call to undefined method mysqli_stmt::get_result()

What other function can I use instead of theget_result() to make sure there are rows in the $result?

if ($stmt = $conn->prepare($query)) {
            $stmt->execute();
            $result = $stmt->get_result();
            if ($result->num_rows > 0) {
            while ($row = $result->fetch_assoc()) {
                 $items[] = $row;
             }
            $stmt->free_result();
            $stmt->close();
            }
            $conn->close();
        }
halfer
  • 19,824
  • 17
  • 99
  • 186
Mona Coder
  • 6,212
  • 18
  • 66
  • 128
  • Verify you're for sure using mysqlnd as your Client Library with mysqli, that function only exists with the Native Driver. That should be the default post 5.4.x, but just make sure. – parttimeturtle Apr 10 '19 at 18:20
  • 1
    Thanks for reply, I already did all of these. still same isuue is happening. so I want to change my code – Mona Coder Apr 10 '19 at 18:23

1 Answers1

-2

Try using $stmt->num_rows and get rid of the get_result

 if ($stmt = $conn->prepare($query)) {
 $stmt->execute();
 if ($stmt->num_rows > 0) { 
while ($row = $stmt->fetch_assoc())         { 
 $items[] = $row;
 }
 $stmt->free_result(); $stmt->close(); 
 } 
$conn->close();
 }
Adam Hull
  • 214
  • 1
  • 8