1
I’m finding the following error in script down below:
Fatal error: Call to a Member Function prepare() on null in C: wamp www cursophp orientacao_object pdo_statement usuarios.php on line 20
Code:
class Usuarios {
private $db;
public function _construct(){
    try{
        $this->$db = new PDO("mysql:dbname=blog;host=localhost", "root", "");
    }catch(PDOException $e){
        echo " Falha na conexão: ".$e->getMessage();
    }
}
public function selecionar($id) {
    $sql = $this->db->prepare("SELECT * FROM usuarios WHERE id=:id");
    $sql->bindValue(":id", $id);
    $sql->execute();
    $array = array();
    if($sql->rowCount() > 0){
        $array = $sql->fetch();
    }
    return $array;
}
That name sounds wrong:
_construct()lacks an underscore ...– rray