I am trying to display an alert box using javascript in my login php file.

When a user logged in using a wrong username or password, then a messagebox will display.

This is what i have so far:

$query="SELECT * FROM info WHERE username ='$user' && password ='$pass' ";
		  $res=mysql_query($query);
		  if (mysql_num_rows($res) == 0) {
		           echo"<script language="javascript">window.alert('Invalid password.')</script>";
				   echo "<br>";
		     }
		   else {
				   echo "Access Granted";
				   echo "<br>";
		         }

Can't figure it out.

You should escape the double quotes in line 4:

echo"<script language=\"javascript\">window.alert('Invalid password.')...

or u can use this
: echo("<script>alert('Invalid password.')</script>");

The answer has already been posted, but for the sake of easiness I'm giving you the complete code:

if (mysql_num_rows($res) == 0) {
echo"<script language='javascript'>window.alert('Invalid password.')</script>";
echo "<br>";
}
else {
echo "Access Granted";
echo "<br>";
}