mysql_num_rows() expects parameter 1 to be resource :S

Been trying to figure this out for the last hour >:( Help is more than welcome. I take it something to do with th query but what?

mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\Website\login.php on line 16

[php]<?php

$username = $_POST[‘username’]; //Gets varable username from from
$password = $_POST[‘password’]; //Gets varable password from from

if($username&&$password)
{

$connect = mysql_connect(“localhost”,“root”,“password”) or die(“Couldn’t connect to server!”); //Connects to server.
mysql_select_db(‘phplogin’) or die (“Couldn’t find DB”); // connects to DB.

$query = mysql_query(“SELET * FROM user WHERE username =’$username’”);

$numrows = mysql_num_rows($query);

if ($numrows !=0)

{
//code to login
}

else

die(“That user doesn’t exist!”);

}

else
die(“Please enter a username and password!”);

?>[/php]

Usually this error means that you have some errors in query. Try to print your query and run it with phpmyadmin or put echo mysql_error(); right after $result=mysql_query($sql);

I hope this will helpful for you…
Reply your feedback
SR

Sponsor our Newsletter | Privacy Policy | Terms of Service