0
I’m making a task scheduling system.
I need to show these tasks to the user, created a file called tarefas.php
to query the Mysql database:
<?php
include_once 'conexao-calendario.php';
include_once 'VerificarLogin.php';
$usuario = $_SESSION['email'];
$sql = "SELECT id, titulo, local, data, horario, status FROM eventos WHERE email = '$usuario' ORDER BY data, hora ";
$select = $pdo->prepare($sql);
$result = $pdo->query($sql);
$dados = $result->fetchAll( PDO::FETCH_ASSOC );
var_dump($dados);
?>
Without the order by
appears the correct array, but with it gives the following error:
Fatal error: Uncaught Error: Call to a Member Function fetchAll() on Boolean in C: xampp htdocs Hope tasks.php:9 Stack trace: #0 {main} thrown in C: xampp htdocs Hope tasks.php on line 9
You have the field
horario
but makes ordination by the fieldhora
. Probably if you looked at the PHP error log you would find the problem. Otherwise, there isprepare
and hasquery
Then it would be good to review which one to use. It has other problems as well, including lack of string sanitization and mix of upper and lower case in includes.– Bacco
Which is line 9?
– user60252
I checked your script and there was no error, the error may be in another part of the code (we include). Use the prepare method and avoid suffering sql Injection
– user60252
You can show the table structure?
– Mauricio Wanderley Martins