Why is the given $ variable not receiving the DB values?

-1
<?php
require'conecta.php';
$id = 0;
if (isset($GET['id']) && !empty($GET['id'])){
    $id = addslashes($GET['id']);

    $sql = "SELECT * FROM usuarios WHERE id = '$id'";
    $sql = $pdo->query($sql);
        if ($sql->rowCount()<0) {
            $dado = $sql->fetch();

        }
}


?>
<form method="POST">
    Nome:</br>
    <input type="text" name="nome" value="<?php echo $dado['nome']; ?>"></br>
    E-mail:</br>
    <input type="text" name="email" value="<?php echo $dado['email']; ?>"></br>
    Senha</br>
    <input type="password" name="senha"></br>
    <input type="submit" value="Atualizar">
</form>
    
asked by anonymous 04.02.2018 / 21:53

1 answer

0

As I remember, in the PDO after assigning the query, you must use ->execute(); to apply the operation.

$sql = $pdo->query($sql);
$sql->execute();
    
04.02.2018 / 22:00