Undefined variable: numrows in C:\xampp\htdocs\csrc\Untitled-1.php on line 16

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nhirene
    New Member
    • Jan 2014
    • 3

    Undefined variable: numrows in C:\xampp\htdocs\csrc\Untitled-1.php on line 16

    Code:
    $query = mysql_query("SELECT * FROM users WHERE username='$username'");
    	$db_rows= '';
    	if ($numrows!=0)
    	{
    		while ($row = mysql_fetch_assoc($query))
    		{
    			$dbusername = $row['username'];
    			$dbpassword = $row['password'];
    		}
    		//check to see if match!;
    		if ($username==$dbusername&&$password==$dbpassword)
    		{
    			//echo "You're IN!";
    			header("location: main.php");
    			$_SESSION['username']=$dbusername;
    		}
    		else
    			echo "Incorrect password!";
    		
    	}
    	else
    Last edited by Rabbit; Jan 15 '14, 04:57 PM. Reason: Please use [CODE] and [/CODE] tags when posting code or formatted data.
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    Please use code tags when posting code or formatted data.

    The error message is pretty clear. You use a variable that you didn't declared.

    Comment

    • Dormilich
      Recognized Expert Expert
      • Aug 2008
      • 8694

      #3
      this whole code is much too complicated (logic-wise). if you want to know, if a certain password matches a certain existing user, ask the DB that directly. i.e.
      Code:
      SELECT COUNT(*) FROM table WHERE username = ? AND password = ?

      Comment

      Working...