I come to you since I am stuck in an object-oriented MySQLi function.
I try to get the ID (A_i) of the corresponding tokens of the users, in a table called Tokens. The problem is that it does not give errors and also returns an empty result.
I clarify that the token I use to test the code is exactly the same as it is in the table, since I basically copy and paste the same, so it is not a problem of non-existence of the same.
I would like to know what I am doing wrong, because I have been stuck for exactly 1 week. Thanks in advance.
I leave the code:
modules / config.php
<?php
$host = "localhost";
$db_user = "root";
$db_pass = "123456";
$database = "database";
$db = new mysqli($host, $db_user, $db_pass, $database);
?>
classes / token.php
<?php
class Token
{
function usuarioToken($token)
{
include("../modules/config.php");
// Seleccion de datos segun token
$sql = "SELECT * FROM 'tokens' WHERE 'token'='".$token."'";
$db->query($sql);
$buffer = [];
while ($data = $db->fetch_assoc) {
$buffer[] = $data["id"];
}
return $buffer;
}
}
?>
verify / index.php
<?php
include("../classes/token.php");
$token = new Token();
print_r( $token->usuarioToken($_GET["t"]) );
?>
Result obtained ...
Array ( )