4
I need to do a log count. I wore:
mysql_num_rows($consulta);
How do I do the same thing using mysqli? Because I’m doing it this way:
$tabela_usuarios = "SELECT * FROM owner WHERE owner_email='$email' AND password='$password' ";
$resul = mysqli_query($con, $tabela_usuarios);
$regs = mysqli_num_rows($resul);
And the following message appears on the screen: "Warning: mysqli_num_rows() expects Parameter 1 to be mysqli_result, null Given in /home/petsm976/public_html/php/logon.php on line 15"
Place the previous snippet to the line of
mysqli_num_rows()
... error says your query(return frommysqli_query()
) failed.– rray
according to the error the variable $query is empty, use
echo $consulta;
orvar_dump($consulta);
to see if there’s anything...– RFL
Tai @rray, the excerpt before mysqli_num_rows, reissued the post and put.
– GustavoSevero
@Rafaelacioly, the variable is not empty... Gave an echo on it, I ran the SQL code of the database and shows data.
– GustavoSevero
echo $tabela_usuarios
shows what ?– Diego Souza
Sincerely @Gustavosevero I suggest you learn PDO because soon mysqli will not "exist", it will be depreciated...
– RFL
@Diegosouza, show this: string(88) "SELECT * FROM Owner WHERE owner_email='[email protected]' AND password='xxx180398' "
– GustavoSevero
Why don’t you use
SELECT COUNT(owner_email) AS TOTAL FROM owner WHERE owner_email='$email' AND password='$password'
, ai you give a fetch on the result and do validation taking the data from the total field.– henriquedpereira
@Henriquedomingospereira, do I have to fetch a result? I don’t know mysqli.
– GustavoSevero
I put as an answer, take a look.
– henriquedpereira
@Rafaelacioly, where do I download the PDO class? Or, how do I install it?
– GustavoSevero
@RFL, so far there is no evidence that mysqli will be depreciated. Now if vc refers to a future possibility, in fact in the future any native function of PHP can become deprecated, it is at the discretion of the developer.
– Skyline