I can not get information to the database using php. Here's the code I've implemented to fetch 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 not figure out why. When I run this querry in phpmyadmin it returns a column so it should enter if
, but it does not go in. Does anyone know where to go wrong?