Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

288
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda