-2

I have this code below. And I have this error:

Warning: mysqli_query() expects at least 2 parameters, 1 given

=========================================================================

$qry = mysqli_query("select * from tbl_users where usr='$unm' and pwd='$pwd'");
$rec_count = mysqli_num_rows($qry);

if($rec_count == 1){
    while($row = mysqli_fetch_array($qry)){
        echo "Welcome " . ucfirst($row['fname']) .  "!";
    }
}
Unheilig
  • 16,196
  • 193
  • 68
  • 98
Markus
  • 1
  • 2
  • Possible duplicate of [mysqli\_query() expects at least 2 parameters, 1 given in?](http://stackoverflow.com/questions/23484158/mysqli-query-expects-at-least-2-parameters-1-given-in) – Your Common Sense Oct 02 '15 at 09:02

1 Answers1

0

Check the documentation. When you create the connection to your database server, that is create a link resource.

For example:

$link = mysqli_connect("127.0.0.1", "my_user", "my_password", "my_db");

when you want to use the mysqli_query, you need to provide this $link to it.

$result = mysqli_query ( $link, $qry);
vaso123
  • 12,347
  • 4
  • 34
  • 64