0

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");


?>
5
Contributors
16
Replies
19
Views
7 Years
Discussion Span
Last Post by ruby21
0

It means you query failed. Add after line 11:

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

Let us know if there is an error.

0

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."'");

Edited by Ezzaral: Snipped url. Keep it on site.

0

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 ..

Edited by ichinpogs1: n/a

0

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");


?>

Edited by mike_2000_17: Fixed formatting

0

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

0

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?

0

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

Edited by muralikalpana: n/a

0

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'");

Edited by ichinpogs1: n/a

0

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'");

Edited by muralikalpana: n/a

0

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

0

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

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.