i cant resolve this error,please help on line 25

<html>
<head>
<title>login in form</title>
<link rel="stylesheet" a href="style.css"/>
</head>
<body>

<?php
$host ="localhost";
$user ="root";
$password = "";
$db = "demo";

mysql_connect($host,$user,$password);
mysql_select_db($db);

if(isset($_POST['username'])){

$username = $_POST['username'];
$password = $_POST['password'];

$sql="SELECT * FROM login where user'".$username."'AND pass='".$password."'limit 1 ";

$result = mysql_query($sql);

  if(mysql_num_rows($result)==1){

	echo "you have sucessfully logged in";
	exit();
}else{
	echo "you have  entered incorrect password";
	exit();
}

}

?>

<div class = "container">
	<img src="bae.jpg">
	<form method = POST action = "#"/>
    <b>LOGIN</b>
	<div class = "form_input">
		<input type = "text"  placeholder="enter your username" name ="username" value="" required/>
	</div>

  <div class="form_input">
  	<input type = "password"  placeholder="enter your password"  name="password" value="password"  required />
  </div>


  <input type = "submit" name = "" value = "LOGIN" id="login"/>

</form>
</div>
</body>
</html>

    It almost always means there was some problem with your query such that the database rejected it, so $result ended up as Boolean false instead of a mysql result resource. Therefore you need to test that $result is not false, and if it is, do some debugging (see mysql_error(), e.g.).

    Oh, and you really shouldn't be using the MySQL PHP extensiont, which has been deprecated for years and is not available in the latest PHP versions. Use either the MySQLi extension or the PDO extension.

      5 days later

      NogDog is correct. mysql has been deprecated (and removed) from recent versions of PHP. You should use mysqli instead.

      Also, you should always check the result of mysql connect and query operations in case they return an error. Like when you connect:

      $conn = mysql_connect($host,$user,$password);
      if (!$conn) {
        die("Could not connect to database!");
      }
      
        Write a Reply...