MySQL query result is giving wrong values : <p>guys! I'm in trouble with my MySQL database. When I try to access the fields it doesn't return the exact value. Here is the code.</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;?php
  $host = "localhost";
	$user = "******";
	$pass = "******";
	$db = mysql_connect($host, $user, $pass) or die("Unable to connect. Check your connection parameters.");
	mysql_select_db("*****") or die("Unable to select database!");
  $form_username=$_POST["username"];
	$form_password=$_POST["password"];
	$query="
		SELECT username, password FROM users
	";
	$result=mysql_query($query,$db) or die("Unable to send the query".mysql_error());
	$index=0;
	while($row=mysql_fetch_row($result))
	{
		$username[$index]=row[0];
		$password[$index]=row[1];
		$index++;
	}
	
	for($i=0; $i&lt;=$index; $i++)
	{
		if($form_username==$username[$i]&amp;&amp; $form_password==$password[$i])
		{
			session_start();
			$_SESSION["login"]="OK";
			header("Location: ************");
			die();
		}
	}</code></pre>
</div>
</div>
</p>

<p>The <strong>if</strong> statement inside the <strong>for</strong> operator returns false for every given value. When I <strong>echo</strong> every username and password like this:</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>echo $form_username." ".$username[0]." ".$form_password." ".$password[0]."&lt;br&gt;";
	echo $form_username." ".$username[1]." ".$form_password." ".$password[1]."&lt;br&gt;";
	echo $form_username." ".$username[2]." ".$form_password." ".$password[2]."&lt;br&gt;";</code></pre>
</div>
</div>
</p>

<p>It <strong>echo</strong> me this:</p>

<p>admin r 12345 o</p>

<p>admin r 12345 o</p>

<p>admin r 12345 o</p>

<p>I really don't know where the problem is.
I'll really appreciate your help.</p>
