Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

269
Views
PHP error (500 internal sever error) while using $stmt->get_result()->fetch_assoc();

I have a function which works like this

public function get_user_by_email($email)
{
    $stmt = $this->con->prepare("SELECT * FROM `user` WHERE `email` = ? ");
    $stmt->bind_param("s", $email);
    $stmt->execute();

    return $stmt->get_result()->fetch_assoc();
}

The problem is whenever I call this function with any email(whether it existed on the database or not) it throws internal server error 500. I'm using a live hosting server and Postman to test this. Can someone help?

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

Try debugging with the following code:

public function get_user_by_email($email)
{
    $stmt = $this->con->prepare("SELECT * FROM `dbname.user` WHERE `email` = ? ");
    $stmt->bind_param("s", $email);
    $stmt->execute();

    $result = $stmt->get_result();
    echo "Result Object: ";
    echo $result;  // If it's OK, it should print "Object ( ... )"

    $arr = $result->fetch_assoc();
    echo "Fetched Object: ";
    echo $arr; // If it's OK, then it'd print "Array ( ... )"

    return $arr;
}
over 4 years ago · Santiago Trujillo Report

0

I experienced this error as well. It is coming from get_result() -> https://www.php.net/manual/en/mysqli-stmt.get-result.php

I built an app using JS, PHP and MySQL. Everything worked well locally but when I uploaded it to a shared server, I start getting 500 Internal Server error (The server host might have thrown 500 error instead of displaying Fatal Error on screen). This got fixed when I disabled mysqli and enabled nd_mysqli from my hosting's PHP extensions.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!