Why is the $given variable not receiving BD values?

Asked

Viewed 25 times

-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>
  • Where is this $GET['id']? coming from if it’s coming from url is with $_GET['id'] that you get it. What’s the content of $GET?

1 answer

0

As I recall, in the PDO after assigning the query, you should use ->execute(); to implement the operation.

$sql = $pdo->query($sql);
$sql->execute();

Browser other questions tagged

You are not signed in. Login or sign up in order to post.