A
A
Aylix2020-04-23 19:31:31
PHP
Aylix, 2020-04-23 19:31:31

Why is 0 rows returned from sql query?

I enter the login and password that matches the database

<form method="POST" action="login.php">
<input type="text" name="login" size="15">

$conn = mysqli_connect("localhost","my_user","sMtWzj6WLNFkrQCa","users");
  if ($conn == false){
    print("Ошибка: Невозможно подключиться к MySQL ".mysqli_connect_error());
  }
  mysqli_set_charset($conn, "utf8");
}
  $qu = "SELECT * FROM data WHERE 'login'='". $_POST["login"] ."' AND 'pass'='". $_POST["pass"]."'";
  $zapros =mysqli_query($conn,$qu);
  
  if($result = mysqli_query($conn,$qu)){
    $rowcount=mysqli_num_rows($result);
  	printf("Result set has %d rows.\n",$rowcount);


I get 0 rows in the output, perhaps an error in the SQL query?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Armenian Radio, 2020-04-23
@gbg

This code contains a SQL Injection vulnerability that is easy to exploit. Read about PDO and Prepared Statements and don't embarrass yourself like that anymore.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question