php - Prepared statement returns 0 instead of 1, why? -
What's the problem with this case? Why do I get 0 instead of 1? If I run a query from phpMyAdmin then it works fine. If $ ($ stmt = $ mysqli- & gt; ready (select "WHERE user name = and password =?")) {$ Input ['hold'] = md5 ($ Input ['pass']. $ Config ['salt']); $ Stmt- & gt; Dam_param ("ss", $ input ['user'], $ input ['hold']); $ Stmt- & gt; Store_result (); $ Stmt- & gt; Executed (); If ($ stmt-> num_rows & gt; 0) {// set session variable $ _SESSION ['username'] = $ input ['user']; Header ("location: member.fp"); // if we have results, redirect it again}
I have no solution , But some comments that are too big for a comment.
The code shown by you will set the session if the result is zero, or fails, as well as when the number of rows is zero, there is no error check to see that the code is executing expectedly Yes or No.
You should check the errors, also try running it with a hard coded SQL statement, which you have verified and verified using PHPMyAdmin's mysql command line client.
Comments
Post a Comment