-1
<?php
require_once("connect.php");

$login1 = $_POST['email'];
$password1 = $_POST['password'];
$select = "SELECT id FROM loginregistration WHERE login ='$login1', password   ='$password1'";
$sql = mysqli_query($con,$select);
$row = mysqli_fetch_assoc($sql);
?>`

it seems that my mysqli_query doesn't work ,what should i do?

Dharman
  • 30,962
  • 25
  • 85
  • 135
  • Possible duplicate of [mysqli\_fetch\_array()/mysqli\_fetch\_assoc()/mysqli\_fetch\_row() expects parameter 1 to be resource or mysqli\_result, boolean given](http://stackoverflow.com/questions/2973202/mysqli-fetch-array-mysqli-fetch-assoc-mysqli-fetch-row-expects-parameter-1) – David Sep 10 '16 at 10:19
  • 1
    The first thing you should do is fix the SQL injection vulnerability (http://stackoverflow.com/questions/60174/how-can-i-prevent-sql-injection-in-php) That way you're actually controlling what query you execute instead of letting the user define their own query. The next thing you should do is check for errors after executing any query, never assume it was successful. The database is telling you what the problem is, but this code ignores that error message. – David Sep 10 '16 at 10:20
  • use concatenate and remove comma near password $select = "SELECT id FROM loginregistration WHERE login ='".$login1."' and password ='".$password1."'"; – JYoThI Sep 10 '16 at 10:26
  • 1
    I disagree with David... The FIRST thing you should do is **stop storing passwords in plain text**!!! Spend some time researching how to manage login credentials securely. – Tom Lord Sep 10 '16 at 15:52
  • Does this answer your question? [mysqli\_fetch\_assoc() expects parameter / Call to a member function bind\_param() errors. How to get the actual mysql error and fix it?](https://stackoverflow.com/questions/22662488/mysqli-fetch-assoc-expects-parameter-call-to-a-member-function-bind-param) – Dharman Jan 06 '20 at 20:46

1 Answers1

1

use AND insted of comma (,) in query near password that's why query returning false and throw that error

$select = "SELECT id FROM loginregistration WHERE login ='".$login1."' and password ='".$password1."'";

UPDATE 1

if query fail it return false . so you can use mysqli_error($con); to know the error

    <?php
    require_once("connect.php");

    $login1 = $_POST['email'];
    $password1 = $_POST['password'];
    $select = "SELECT id FROM loginregistration WHERE login ='".$login1."' AND password   ='".$password1."'";
    $sql = mysqli_query($con,$select);

    if($sql === FALSE) { 
        die(mysqli_error($con)); // better error handling
    }

    $row = mysqli_fetch_assoc($sql);
    ?>
JYoThI
  • 11,977
  • 1
  • 11
  • 26