0
How do I know how many records I have returned from a SELECT statement? I tried using rowCount() but this did not work in my code, I just want to return to me the amount only this.
$contador = $this->con->conectar()->prepare("SELECT * FROM login WHERE 'usuario' =:usuario AND 'senha' =:senha");
$contador->bindPARAM(":usuario", $this->usuario, PDO::PARAM_STR);
$contador->bindPARAM(":senha", $this->senha, PDO::PARAM_INT);
$contador->execute();
echo $contador->rowCount();
$number = $counter->rowCount(); echo $number;
– Everton Figueiredo
Did not work with this code Everton it shows result 0, and in the BD contains the user and password.
– sol25lua
In this case you don’t even need, how many lines can you have with the same username and password? If there are more than
umrethink your table!– user60252
SELECT * FROM login WHERE 'usuario' =:usuario AND 'senha' =:senha- It shouldn’t just beSELECT * FROM login WHERE usuario = :usuario AND senha = :senha? That is, without the apostrophes?– Victor Stafusa
I tried so and also did not work SELECT * FROM login WHERE usuario =:user AND password =:password, I do not know where I am missing
– sol25lua
missing $ in variables where user =:$user AND password =:$password
– user60252
Read this post https://answall.com/questions/87384/qual-a-diferen%C3%A7a-entre-bindparam-e-bindvalue
– user60252