-1

I am getting these errors:

1- mysqli_query() expects at least 2 parameters, 1 given in C:\wamp\www\index.php on line 13. 2- Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, null given in> C:\wamp\www\index.php on line 14.

I am using wamp server. When I use mysql command its says to me to use mysqli and I have no experience with mysqli.

Here are my two lines

<?php
session_start();
include_once 'dbconnect.php';

if(isset($_SESSION['user'])!="")
{
 header("Location: home.php");
}
if(isset($_POST['btn-login']))
{
 $email = mysqli_real_escape_string($con, $_POST['email']);
 $upass = mysqli_real_escape_string($con, $_POST['pass']);
 $res=mysqli_query("SELECT * FROM users WHERE email='$email'");
 $row=mysqli_fetch_array($res);
 if($row['password']==md5($upass))
 {
  $_SESSION['user'] = $row['user_id'];
  header("Location: home.php");
 }
 else
 {
  ?>
        <script>alert('wrong details');</script>
        <?php
 }

}
?>

Please help me

mario.van.zadel
  • 2,919
  • 14
  • 23

1 Answers1

0

mysqli_query needs two parameter. First is your database connection and second one is query srting.

So add $con as first parameter

mysqli_query($con,"SELECT * FROM users WHERE email='$email'");
Saty
  • 22,443
  • 7
  • 33
  • 51