Hi sir pls help i have an error in line 13 .. and still i don't no where can i find this error...

Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\wamp\www\login.php on line 13

<?php
                        $username  = $_POST['username'];
                        $password =  $_POST['password'];

                        if ($username&&$password)
                        {
                          
                          $connect = mysql_connect("localhost","root","") or die ("Couldn't Connect!");
                          mysql_select_db("phplogin") or die ("Couldn't find db");

                          $query = mysql_query("SELECT * FROM users WHERE username = '$username'");

                          $numrows = mysql_num_rows($query);
                          echo $numrows;

                        }
                        else

                             die("Please enter a username and password");


?>

It means you query failed. Add after line 11:

if (!$query) die(mysql_error());

Let us know if there is an error.

Hi sir pls help i have an error in line 13 .. and still i don't no where can i find this error...

Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\wamp\www\login.php on line 13

<?php
                        $username  = $_POST['username'];
                        $password =  $_POST['password'];

                        if ($username&&$password)
                        {
                          
                          $connect = mysql_connect("localhost","root","") or die ("Couldn't Connect!");
                          mysql_select_db("phplogin") or die ("Couldn't find db");

                          $query = mysql_query("SELECT * FROM users WHERE username = '$username'");

                          $numrows = mysql_num_rows($query);
                          echo $numrows;

                        }
                        else

                             die("Please enter a username and password");


?>

for mysql_num_rows() to return a value the supplied argument must be a mysql result set.

there is an error in your sql
try changing the line

$query = mysql_query("SELECT * FROM users WHERE username = '$username'");

to

$query = mysql_query("SELECT * FROM users WHERE username = '".$username."'");

It means you query failed. Add after line 11:

if (!$query) die(mysql_error());

Let us know if there is an error.

hi Master! i do what u said

$query = mysql_query("SELECT * FROM users WHERE username ='$username'");
     if (!$query) die(mysql_error());

and i got this message " Table 'phplogin.users' doesn't exist"

if the table that he means is the error well i have one already..

is this the table that he mean in the Database i have "phplogin" under that is the "user" the table is look like this.

id    username   password
	   	                       1    alex 	  abc

Sorry for this i am trying hard to learn this ..

when i add this if (!$query) die(mysql_error()); now i got this error
"Table 'phplogin.users' doesn't exist"

<?php
                        $username  = $_POST['username'];
                        $password =  $_POST['password'];

                        if ($username&&$password)
                        {

                          $connect = mysql_connect("localhost","root","") or die ("Couldn't Connect!");
                          mysql_select_db("phplogin") or die ("Couldn't find db");

                          $query = mysql_query("SELECT * FROM users WHERE username = '$username'");

 if (!$query) die(mysql_error());

                          $numrows = mysql_num_rows($query);
                          echo $numrows;

                        }
                        else

                             die("Please enter a username and password");


?>

you got

" Table 'phplogin.users' doesn't exist"

this message.
but you wrote your dbname

"phplogin"

and tablename

"user"

check your table name users or user

you got

" Table 'phplogin.users' doesn't exist"

this message.
but you wrote your dbname

"phplogin"

and tablename

"user"

check your table name users or user

I got the table name

My Database name

"phplogin(1)"

table name
"user"


and i got this error message " Table 'phplogin.users' doesn't exist "
what am i suppose to replace?

you got "users" table doesn't exist. but your table name is user. remove 's'.

use this query

$query = mysql_query("SELECT * FROM user WHERE username = '$username'");

waaaaaaaaaaaaaaaa its working now! what happen... thank u ^^

use this query its enough.

$query = mysql_query("SELECT * FROM user WHERE username = '$username'");

use this query

$query = mysql_query("SELECT * FROM user WHERE username = '$username'");

its working now it respond "1"


i don't see any different between this

$query = mysql_query("SELECT * FROM user WHERE username = '$username'");

and this and this code that i post

$query = mysql_query("SELECT * FROM users WHERE username = '$username'");

you don't see any difference. you got "users" table does not exists. but your table name is "user". so how you can selects rows from 'users' table. you wrote like this

$query = mysql_query("SELECT * FROM users WHERE username = '$username'");

just i changed table name "users" as "user"

$query = mysql_query("SELECT * FROM user WHERE username = '$username'");

oh i see so that's the table to be adjusted yay! thank u so much .. i feel so haaaapy :)

what is the meaning of this mysql_num_rows() expects parameter 1 to be resource, boolean given in

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.