-1
I can’t get information from the database using php. See the code I implemented to get this information:
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT pergunta, resA, resB,resC,resD,resE,acertaram,falharam,dificuldade,resposta,imgSrc FROM perguntas Where ID = 1"; //This is where I specify what data to query
$result = mysqli_query($conn, $sql);
if(mysql_num_rows($sql)){
echo $result;
} else echo '<h1 style=" font-size: 30px; font-color: red ">ERRO AO PESQUISAR<h1><br /> <p>Ocorreu um erro enquanto se processava a querry.</p>';
The result is always the last echo
and I can’t figure out why. When I run this querry on phpmyadmin it returns a column so it should enter the if
, but it doesn’t. Someone can tell me where I went wrong?
It remains exactly the same after the exchange. It seems that it does not return anything here
$result = mysqli_query($conn, $sql);
– ihavenokia
Sey SGBD? I don’t know what this is, but as had said in phpmyadmin it returns a column
– ihavenokia
SGBD is a system or software that you manage the database, like Phpmyadmin. I changed my answer, give a read.
– Diego Souza
I can’t believe I fell for that. That’s how you get into
if
(even without the comparison), I can conclude that he searched the information of the corresponding column?– ihavenokia
You can. You don’t need the comparison. If it’s bigger than
0
automatically is TRUE, then it enters theif
.– Diego Souza