Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to remove this mysqli warning?
    primarykey
    data
    text
    <p>I am doing an update in my php/mysqli. The update works fine but the problem I have is that I keep getting this warning:</p> <p>Warning: mysqli_stmt::fetch() [mysqli-stmt.fetch]: (HY000/2053): Attempt to read a row while there is no result set associated with the statement in on line 44.</p> <p>Because I keep getting this warning, it means that after the user submits the form, even with the correct username typed it, it still displays the message "The Username you Entered is not Valid. Try Entering it Again." when really it should navigate the user to the thankyou.php page.</p> <p>So my question is how do I remove this warning?</p> <pre><code> $username = (isset($_POST['username'])) ? $_POST['username'] : ''; $newpassword = (isset($_POST['newpassword'])) ? $_POST['newpassword'] : ''; $loggedIn = false; if (isset($_POST['submit'])) { // don't use $mysqli-&gt;prepare here $query = "UPDATE Teacher SET TeacherSalt = ?, TeacherPassword = SHA1(CONCAT(?,?)) WHERE TeacherUsername = ? LIMIT 1"; // prepare query $stmt=$mysqli-&gt;prepare($query); // You only need to call bind_param once $stmt-&gt;bind_param("ssss",$salt,$newpassword,$salt,$username); // execute query //bind results $stmt-&gt;bind_result($dbTeacherUsername,$dbTeacherPassword,$dbTeacherSalt); $stmt-&gt;execute(); while($stmt-&gt;fetch()) { if ($username == $dbTeacherUsername) { $loggedIn = true; } } /* close statement */ $stmt-&gt;close(); /* close connection */ $mysqli-&gt;close(); if ($loggedIn == true){ $_SESSION['username'] = $dbTeacherUsername; header( 'Location: thankyou.php' ) ; die(); } } if ($loggedIn == false &amp;&amp; $_POST) { echo "The Username you Entered is not Valid. Try Entering it Again."; } ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload