Answer the question
In order to leave comments, you need to log in
What is the reason for the fetch_assoc() error?
$servername = 'localhost';
$username = 'root';
$password = '';
$dbname = '1';
$mysqli = new mysqli($servername, $username, $password, $dbname);
$login = $_POST["login"];
$password = $_POST["password"];
$nick = $mysqli->query("SELECT * FROM 'accounts'");
$result = $nick->fetch_assoc();
var_dump( $result );
Throws an error: "Fatal error: Uncaught Error: Call to a member function fetch_assoc()"
Answer the question
In order to leave comments, you need to log in
With the fact that the request is not correct - '' around the table name is not in place. And in the end, you returned FALSE, not mysqli_result.
Besides, it is better to use PDO.
query
can return false, you do not have a check for this and you suffer from showing an error, and the error is most likely that you need to use apostrophes (`) for the names of tables and fields, and quotes for text. You have the name of the table in quotation marks, i.e. need`accounts`
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question