warning :: invalid object or resource mysqli_stmt. What is the meaning and solution(s)?

后端 未结 1 2012
别那么骄傲
别那么骄傲 2020-12-11 10:26

The following code is throwing the mysterious Warnings. I can\'t understand what they mean. What do these errors indicate and how to eradicate them?

require          


        
相关标签:
1条回答
  • 2020-12-11 11:11

    The problem here is quite peculiar. It sounds unrelated but this error message is the result of unreliable syntax variant.

    Procedural mysqli syntax is not only excessively verbose as compared to object syntax, but also deceptive, raising an error not when it really occurs, but when it's already too late, not to mention the cryptic nature of this error message.

    There is some problem with your query and you need to get the real error message from MySQL as explained in this answer but in order to implement it you have to change the syntax.

    Takeaway: to solve your problem

    1. rewrite your conn.php as shown in this my article to set the proper connection settings
    2. rewrite your procedural mysqli to object syntax, such as

      $query = "SELECT userid FROM users WHERE email = ?";
      $stmt = $dbconn->prepare($query);
      $stmt->bind_param("s", $email);
      $stmt->execute();
      $result = $stmt->get_result();
      
    3. get the real error message

    4. if the error is already clear then just fix it, or otherwise google for the better explanation

    and after that you'll be able to fix the issue.

    0 讨论(0)
提交回复
热议问题