-2

I am building a user login form validation. On correct, password user will be able to go to user access area. The error has occurred on the below line.

$query = mysqli_query ("select * from tb_cform where u_pass='$pass' AND u_username='$username' ",$connection);

The error I get is the following:

Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, null

SuperDJ
  • 7,488
  • 11
  • 40
  • 74
  • Your warning is generated when you call `mysqli_num_rows()` (or a function that calls it), not the one you're showing... – joanolo Feb 05 '17 at 11:25

1 Answers1

0

Change:

$query = mysqli_query ("select * from tb_cform where u_pass='$pass' AND u_username='$username' ",$connection);

to:

$query = mysqli_query ($connection, "SELECT * FROM `tb_cform` WHERE `u_pass` = '$pass' AND `u_username` = '$username' ");

You need to pass the connection first. Wrapping table and column names in backticks will prevent mysql reserved words error. Also Selecting everything from a table is bad as it will reduce savety and speed.

SuperDJ
  • 7,488
  • 11
  • 40
  • 74