Code:

$db = mysqli_connect("localhost","root","54825482","MyO"); $result = mysqli_query("SELECT id FROM users WHERE login = '$login'" ,$db) or die('Cann`t query '.mysql_error); 

Mistake:

mysqli_query () expects parameter 1 to be mysqli, string given in C: \ www ... Cann`t query mysql_error

I can not understand what the problem

3 answers 3

 $db = mysqli_connect("localhost","root","54825482","MyO"); $result = mysqli_query($db,"SELECT id FROM users WHERE login = '$login'"); 
  • one
    This answer, like all the others, at the moment, contains an alleged (with a high probability) vulnerability such as SQL injection . - Visman
 $db = mysqli_connect("localhost","root","54825482","MyO"); $sql = "SELECT id FROM users WHERE login = '$login'"; $result = mysqli_query($db, $sql); if (!$result) die('Can`t query '. mysql_error); 

Procedural style

mysqli_query ( mysqli $link , string $query [, int $resultmode MYSQLI_STORE_RESULT ] )

mysqli_query

     $mysqli = new mysqli("localhost","root","54825482","MyO"); $result = $mysqli->query("SELECT id FROM users WHERE login = '$login'"); 
    • In " " you can simply write a variable. echo "Hello $world"; - user242433
    • Not only is this different - Masiama