I want to bring an email from the users table. It is a local database, and it accesses it well because the condition is confirmed. I have an input, that I must put an email, and look for the email that I put in the input in the database and that they match.
<?php
if (!empty($_POST['operar'])){
if (strlen($_POST['entrada']) > 9){ //valida que el campo no este vacio y que sea mayor de 9
if ($linkConexion!=false){
$var = $_POST['entrada'];
$sql = "SELECT email FROM usuarios WHERE email = ' " . $var . "'";
$rs = mysqli_query($linkConexion, $sql);
while ($registro = mysqli_fetch_array($rs)){
if(strcmp($registro,$var) == 0) {//si devuelve 0 son iguales. Se compara cadenas de tx
?>
<div class="alert alert-success">
<p class="m-none text-semibold h6">
Listo! Tu cuenta se encuentra activa nuevamente. </p>
</div>
<?php
} else {
?>
<div class="alert alert-warning">
<p class="m-none text-semibold h6">
<p class="m-none text-semibold h6"> Ingrese un Email correcto </p>
</div>
<?php
}
}
} else {
}
} else {
}
}
?>
For me the error is in the while ($registro = mysqli_fetch_array($rs)){
the problem seems to be in the sql line:
you have a white space between the ' and the ", it should be:
Therefore, in the following line he
mysqli_query
is returning you a$rs = null
:and therefore your while line gives an error, because mysqli_fetch_array is receiving a null as a parameter: