Warning: mysqli_real_escape_string() [duplicate]

29
October 20, 2018, at 01:00 AM

This question already has an answer here:

  • PHP Error: Mysqli_real_escape_string() expects exactly 2 parameters, 1 given 5 answers
  • Can I mix MySQL APIs in PHP? 4 answers

Warning: mysqli_real_escape_string() expects exactly 2 parameters, 1 given in C:\xampp\htdocs\native\admin\process_login.php on line 18

Warning: mysqli_real_escape_string() expects exactly 2 parameters, 1 given in C:\xampp\htdocs\native\admin\process_login.php on line 18

Warning: mysqli_query() expects parameter 1 to be mysqli, string given in C:\xampp\htdocs\native\admin\process_login.php on line 40enter code here Query failed

How to fix ??

<?php 
include '../connect.php';
session_start();
function clean($str) {
        $str = @trim($str);
        if(get_magic_quotes_gpc()) {
            $str = stripslashes($str);
        }
        return mysqli_real_escape_string($str);
    }
    //Sanitize the POST values
    $login = clean($_POST['username']);
    $password = clean($_POST['password']);
    //Input Validations
    if($login == '') {
        $errmsg_arr[] = 'Username missing';
        $errflag = true;
    }
    if($password == '') {
        $errmsg_arr[] = 'Password missing';
        $errflag = true;
    }
    //If there are input validations, redirect back to the login form

    //Create query
    $qry="SELECT * FROM table_admin WHERE username='$login' AND password='$password'";
    $result=mysqli_query($qry,$conn);
    //Check whether the query was successful or not
    if($result) {
        if(mysqli_num_rows($result) > 0) {
            //Login Successful
            session_regenerate_id();
            $member = mysql_fetch_assoc($result);
            $_SESSION['SESS_MEMBER_ID'] = $member['id'];
            $_SESSION['SESS_FIRST_NAME'] = $member['name'];
            $_SESSION['SESS_LAST_NAME'] = $member['email'];
            $_SESSION['SESS_PRO_PIC'] = $member['file'];
            session_write_close();
            header("location: index.php");
            exit();
        }else {
  echo '<script language = "javascript">';
  // echo "window.location.href='login.php'"; 
  echo "alert('Something went wrong, Enter correct details');window.location.href='login.php'";
   echo '</script>';
    exit;
   // echo "<script language = 'javascript'> alert('Wrong Details');'</script>";

                    }`enter code here`
    }else {
        die("Query failed");
    }
?>
READ ALSO
Session in AJAX php file is not updating

Session in AJAX php file is not updating

I am facing a problem with updating the value of my SESSION named "subs"When I click to

28
Check if variable exist with dynamic variable name and dynamic key name and deepness

Check if variable exist with dynamic variable name and dynamic key name and deepness

what is the correct syntax to use isset with a dynamic variable name and dynamic key name, without writing the keyname in braces

30
What is the difference between these 2 ways of exporting from a Javascript module?

What is the difference between these 2 ways of exporting from a Javascript module?

I'm new to JS modules and am confused by the following:

27