Bonjour, je fais une todo list avec comme technologie MySQL, PHP, jQuery et ajax.

Pour le moment mon read et insert dans ma DB fonctionne.

par contre lorsque je click sur le bouton update d'une tâche, j'ai cette erreur, qui me renvoi dans la fonction qui va récupérer la tâche à modifier via son id.
<br />
<font size='1'><table class='xdebug-error xe-notice' dir='ltr' border='1' cellspacing='0' cellpadding='1'>
<tr><th align='left' bgcolor='#f57900' colspan="5"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>( ! )</span> Notice: Undefined property: Database::$db_connexion in C:\wamp64\www\todo-list-v3\Crud.php on line <i>52</i></th></tr>
<tr><th align='left' bgcolor='#e9b96e' colspan='5'>Call Stack</th></tr>
<tr><th align='center' bgcolor='#eeeeec'>#</th><th align='left' bgcolor='#eeeeec'>Time</th><th align='left' bgcolor='#eeeeec'>Memory</th><th align='left' bgcolor='#eeeeec'>Function</th><th align='left' bgcolor='#eeeeec'>Location</th></tr>
<tr><td bgcolor='#eeeeec' align='center'>1</td><td bgcolor='#eeeeec' align='center'>0.0001</td><td bgcolor='#eeeeec' align='right'>403864</td><td bgcolor='#eeeeec'>{main}( )</td><td title='C:\wamp64\www\todo-list-v3\action.php' bgcolor='#eeeeec'>...\action.php<b>:</b>0</td></tr>
<tr><td bgcolor='#eeeeec' align='center'>2</td><td bgcolor='#eeeeec' align='center'>0.0001</td><td bgcolor='#eeeeec' align='right'>405016</td><td bgcolor='#eeeeec'>Crud->getTaskById( )</td><td title='C:\wamp64\www\todo-list-v3\action.php' bgcolor='#eeeeec'>...\action.php<b>:</b>81</td></tr>
</table></font>
<br />
<font size='1'><table class='xdebug-error xe-uncaught-exception' dir='ltr' border='1' cellspacing='0' cellpadding='1'>
<tr><th align='left' bgcolor='#f57900' colspan="5"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>( ! )</span> Fatal error: Uncaught Error: Call to a member function prepare() on null in C:\wamp64\www\todo-list-v3\Crud.php on line <i>52</i></th></tr>
<tr><th align='left' bgcolor='#f57900' colspan="5"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>( ! )</span> Error: Call to a member function prepare() on null in C:\wamp64\www\todo-list-v3\Crud.php on line <i>52</i></th></tr>
<tr><th align='left' bgcolor='#e9b96e' colspan='5'>Call Stack</th></tr>
<tr><th align='center' bgcolor='#eeeeec'>#</th><th align='left' bgcolor='#eeeeec'>Time</th><th align='left' bgcolor='#eeeeec'>Memory</th><th align='left' bgcolor='#eeeeec'>Function</th><th align='left' bgcolor='#eeeeec'>Location</th></tr>
<tr><td bgcolor='#eeeeec' align='center'>1</td><td bgcolor='#eeeeec' align='center'>0.0001</td><td bgcolor='#eeeeec' align='right'>403864</td><td bgcolor='#eeeeec'>{main}( )</td><td title='C:\wamp64\www\todo-list-v3\action.php' bgcolor='#eeeeec'>...\action.php<b>:</b>0</td></tr>
<tr><td bgcolor='#eeeeec' align='center'>2</td><td bgcolor='#eeeeec' align='center'>0.0001</td><td bgcolor='#eeeeec' align='right'>405016</td><td bgcolor='#eeeeec'>Crud->getTaskById( )</td><td title='C:\wamp64\www\todo-list-v3\action.php' bgcolor='#eeeeec'>...\action.php<b>:</b>81</td></tr>
</table></font>
ma connexion à ma db:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php
 
//Class pour la connexion à ma DB.
class Database {
 
    private $serverName;
    private $db_user;
    private $db_pass;
    private $db_name;
    private $charset;
    private $pdo;
 
    function db_connexion() {
        $this->serverName = 'localhost';
        $this->db_user = 'root';
        $this->db_pass = 'password';
        $this->db_name = 'todo_list';
        $this->charset = 'utf8mb4';
 
        if ($this->pdo === null) {//vérifie qu'une instance du PDO n'est pas déjà créée
            try {
                $dsn = "mysql:host=" . $this->serverName . ";dbname=" . $this->db_name . ";charset=" . $this->charset;
                $pdo = new PDO($dsn, $this->db_user, $this->db_pass);
                $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);//permet l'affichage des erreurs
                return $pdo;
            } catch (PDOException $e) {
                echo "erreur connexion à la base de données : " . $e->getMessage();
            }
        }
    }
}
ma fonction qui va rechercher la tâche d'après son id, l'erreur crud.php ligne 52, renvoi ici à la ligne 5.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
//Fonction qui va lire une tâche dans la DB sur base de son id.
    public function getTaskById($id) {
        $db = new Database;
        $sql = "SELECT * FROM tasks WHERE id = :id";
        $stmt = $db->db_connexion->prepare($sql);
        $stmt->execute(['id' => $id]);
        $result = $stmt->fetch(PDO::FETCH_ASSOC);//renvoi un tableau d'attributs
        return $result;
        //$stmt = null;
    }
le traitement du formulaire de modification, l'erreur action.php ligne 81 renvoi ici à la ligne 5:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
//Traitement formulaire update d'une tâche.
if(isset($_POST['edit_id'])){
    $id = $_POST['edit_id'];
    //echo "id= " .$id;
    $row = $crud->getTaskById($id);
    echo json_encode($row);
    //$("#id").val(data.id);   
}

après plusieurs pistes sur google sans résultat, je suis à cours d'idées.