Catchable fatal error: Object of class PDOStatement could not be converted to string in line 114

后端 未结 3 652
南方客
南方客 2020-12-02 00:45

I\'m trying to add some data to my database, but I\'m getting the error Catchable fatal error: Object of class PDOStatement could not be converted to string in /var/www/mand

3条回答
  •  北荒
    北荒 (楼主)
    2020-12-02 01:21

    foreach($_SESSION["cart"] as $id => $value)
    {
    
            $query = $db->query('SELECT * FROM Producten WHERE ProductID ="'.$id.'" ');
            $query->execute();
    
            while($row = $query->fetch(PDO::FETCH_ASSOC))
            {
    
                $price = $row['Prijs'];
                $ProductID = $row['ProductID'];
    
            }
    
    $array = array( $max, $ProductID, $value, $price );
    
    $sql->prepare
        ("
        INSERT INTO Bestellingsdetail (Bestelnummer, ProductID, Aantal, Prijs)
        VALUES (?, ?, ?, ?)
        ")
    
    $sql->execute($array);
    
    }
    

提交回复
热议问题