尝试在数据库中插入数据,但php抛出无效的参数编号,
$stmt =$pdo->prepare('
INSERT INTO '.$_POST['option'].'
(id,title,description,image,date,city,user,price)
values (null,:titl,:desc,:img,:dte,:cty,:user,:prce)');
$stmt->execute( array(
':titl'=>$_POST['title'],
':desc'=>$_POST['description'],
':img'=>$item_img,
':dte'=>$date,
':city'=>$_POST['city'],
':user' =>$_POST['name'],
':prce' =>$price,));
我缺少什么?
答案 0 :(得分:-1)
问题是,
之后的最后$price
以及:cty
错字。请尝试以下方法:
$stmt->execute(
array(
':titl' => $_POST['title'],
':desc' => $_POST['description'],
':img' => $item_img,
':dte' => $date,
':cty' => $_POST['city'],
':user' => $_POST['name'],
':prce' => $price
)
);