Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8533823
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T10:03:15+00:00 2026-06-11T10:03:15+00:00

I am receiving a fatal error in my php/mysqli code which states that on

  • 0

I am receiving a fatal error in my php/mysqli code which states that on line 46:

Fatal error: Call to undefined method mysqli_stmt::fetch_assoc() in ...

I just want to know how can I remove this fatal error?

The line of code it is pointing at is here:

$row = $stmt->fetch_assoc();

ORIGINAL CODE:

$query = "SELECT Username, Email FROM User WHERE User = ?";
// prepare query
$stmt=$mysqli->prepare($query);
// You only need to call bind_param once
$stmt->bind_param("s",$user);
// execute query
$stmt->execute(); 
// get result and assign variables (prefix with db)
$stmt->bind_result($dbUser, $dbEmail);
//get number of rows
$stmt->store_result();
$numrows = $stmt->num_rows();                                      

if ($numrows == 1){

$row = $stmt->fetch_assoc();
$dbemail = $row['Email'];

}

UPDATED CODE:

$query = "SELECT Username, Email FROM User WHERE User = ?";
// prepare query
$stmt=$mysqli->prepare($query);
// You only need to call bind_param once
$stmt->bind_param("s",$user);
// execute query
$stmt->execute(); 
// get result and assign variables (prefix with db)
$stmt->bind_result($dbUser, $dbEmail);
//get number of rows
$stmt->store_result();
$numrows = $stmt->num_rows();                                      

if ($numrows == 1){    
  $row = $stmt->fetch_assoc();
  $dbemail = $row['Email'];    
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T10:03:16+00:00Added an answer on June 11, 2026 at 10:03 am

    The variable $stmt is of type mysqli_stmt, not mysqli_result. The mysqli_stmt class doesn’t have a method “fetch_assoc()” defined for it.

    You can get a mysqli_result object from your mysqli_stmt object by calling its get_result() method. For this you need the mysqlInd driver installed!

    $result = $stmt->get_result();
    row = $result->fetch_assoc();
    

    If you don’t have the driver installed you can fetch your results like this:

    $stmt->bind_result($dbUser, $dbEmail);
    while ($stmt->fetch()) {
        printf("%s %s\n", $dbUser, $dbEmail);
    }
    

    So your code should become:

    $query = "SELECT Username, Email FROM User WHERE User = ?";
    // prepare query
    $stmt=$mysqli->prepare($query);
    // You only need to call bind_param once
    $stmt->bind_param("s",$user);
    // execute query
    $stmt->execute(); 
    // bind variables to result
    $stmt->bind_result($dbUser, $dbEmail);
    //fetch the first result row, this pumps the result values in the bound variables
    if($stmt->fetch()){
        echo 'result is ' . dbEmail;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

receiving error: PHP Notice: Undefined index: mode in /web/ee_web/include/form-modal.php on line 51 line 51
I'm receiving this fatal error message: Using $this when not in object context. This
I receiving a undefined reference error when try to compile an c++ program. I'm
I am receiving a parse error which is this: Parse error: syntax error, unexpected
Im receiving error C2082: redefinition of formal parameter 'rval' in this code while trying
I'm receiving this error for some odd reason: Fatal error: Class 'crud_model' not found
I'm trying to run git clone and am receiving the following error: fatal: Out
I am receiving 2 errors in my code below: Warning: mysqli::prepare() [mysqli.prepare]: (21S01/1136): Column
This is the error I am receiving: Fatal error: Class 'Validate' not found in
The following is the output for issuing init-submodules.sh . I keep receiving this error:fatal

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.