<分区>
我正在尝试向我的数据库中添加一些数据,但我在第 114 行的/var/www/mandje.php 中收到错误 Catchable fatal error: Object of class PDOStatement could not be converted to string in/var/www/mandje.php。 这是我正在使用的代码:
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'];
}
$sql="INSERT INTO Bestellingsdetail( Bestelnummer, ProductID, Aantal, Prijs)
VALUES ($max,$ProductID,$value,$price)"; //<---- line 114
$count = $db->execute($sql);
我真的不明白这里出了什么问题。任何帮助将不胜感激:)