my query is at the end.
<?php
$usu = $_REQUEST["usu"];
$con = $_REQUEST["con"];
$conexion = mysqli_connect("localhost","root","mysql","android");
$res = mysqli_query($conexion, "select * from profesor
where usuario='$usu' and contra='$con'")or die(mysqli_error($res));
/*'".mysqli_real_escape_string($conexion, $usu)."'*/
$q = "select * from profesor where usuario = '$usu' and contra = '$con'"." <br/>";
echo "ESTO SALE DE LA VARIABLE sq Y CONTIENE --> $q";
if($res == null){
echo "No hay nadie con el usuario y contraseña insertado";
}else{
echo "Sí hay alguien con el usuario y contraseña insertado"."<br/>";
}
$datos = array();
foreach ((array) $res as $row){
$datos[]=$row;
}
$final = json_encode($datos);
echo $final;
?>
This is my current BD, this bd is just a test, to practice, so I can show it quietly:
Now the following image is this: The first line is to see if there is someone with the user and password inserted, and correctly I know that it exists. The second is the if I did to see if there is record found in the variable "q". This sentence is shown to me in my browser "select * from teacher where user = 'gezer' and against = 'hello'" I have run it in phpmyadmin and it shows me the field correctly.
I hope you let me understand, now my query is because in line 3 I get: [], as if the arrangement was empty, I think I would have to leave the data of the person with that username and password.