Note that there are some explanatory texts on larger screens.

plurals
  1. POmysqli_num_rows = 0 when it should be 1
    text
    copied!<p>I've been trying to resolve this problem on my own and for the life of me can't fix it..</p> <pre><code>//If they are, retreive them from the Person table var_dump($_POST['username']); var_dump($_POST['password']); $select = $this-&gt; doQuery("SELECT * FROM Person WHERE username = '{$_POST['username']}' AND password = '".md5($_POST['password'])."'"); var_dump($select); try { if (mysqli_num_rows($select) &gt; 0){ var_dump(mysqli_num_rows($select)); //fetching username and password from database $fetch_array = mysqli_fetch_assoc($select); var_dump($fetch_array); //Building a session for the user $_SESSION['username'] = $fetch_array['username']; //var_dump($_SESSION['username']); //Redirecting the user to the index page header('Location:index.php'); return true; } </code></pre> <p>The two var_dumps on the username and password on the 4th and 5th lines returned this: </p> <pre><code>string(8) "johnny03" string(9) "password3" object(mysqli_result)#3 (5) { ["current_field"]=&gt; int(0) ["field_count"]=&gt; int(8) ["lengths"]=&gt; NULL ["num_rows"]=&gt; int(0) ["type"]=&gt; int(0) } </code></pre> <p>The values that I entered for both the password and username are both valid (they are in the database under the correct columns, trust me). I have a feeling that something is wrong with my select query because the var dump on mysqli_num_rows($select) doesn't return anything.That being said, I've tried just about every change to the query that I could think of to make it work and still nothing :[ Can anyone help? </p>
 

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