PHP: Call to a member function execute() Hatası! (çözüldü)
Arkadaşlar basit bir içerik ekleme sistemi yazdım içerikleri ekliyorum sorunsuz çalışıyor fakat 3 yada 4. içeriği eklerken aşağıdaki hatayı veriyor nerede yanlışlık yapıyorum ?
Fatal error: Uncaught Error: Call to a member function execute() on bool in C:xampphtdocsprojectadminsettingsislem.php:218 Stack trace: #0 {main} thrown in C:xampphtdocsprojectadminsettingsislem.php on line 218
https://i.hizliresim.com/7Wcpf8.png
if(isset($_POST['content_add'])){
//$uploads_dir="../../assets/uploads/content";
$mysql_add_content=$conn->prepare("insert into content(c_title,c_title_en,c_description,c_description_en,c_date)values(
'".$_POST["c_title"]."',
'".$_POST["c_title_en"]."',
'".$_POST["c_description"]."',
'".$_POST["c_description_en"]."',
'".$_POST["c_date"]."')");
if($mysql_add_content->execute()){
$last_id = $conn->insert_id;
Header("Location:../slider-ekle.php?durum=ok");
$r1=rand(20000,32000);
$r2=rand(20000,32000);
$uploaded_images = array();
foreach($_FILES['upload_images']['name'] as $key=>$val){
$upload_dir = "../../assets/uploads/content/";
$upload_file = $upload_dir.$r1.$_FILES['upload_images']['name'][$key];
$filename = $r1.$_FILES['upload_images']['name'][$key];
if(@move_uploaded_file($_FILES['upload_images']['tmp_name'][$key],$upload_file)){
$uploaded_images[] = $upload_file;
$insert_sql = "INSERT INTO photos(c_id, url, upload_time)
VALUES('$last_id', '".$filename."', '".time()."')";
$run=$conn->prepare($insert_sql);
if($run->execute()){
Header("Location:../icerik.php?durum=ok");
}else
Header("Location:../icerik.php?durum=error");
}
}
}
}
<?php
if(isset($_POST['content_add'])){
//$uploads_dir="../../assets/uploads/content";
$query = $db->prepare("INSERT INTO content SET
c_title = ?,
c_title_en = ?,
c_description = ?,
c_description_en = ?,
c_date = ? ");
$insert = $query->execute(array(
$_POST['c_title'],
$_POST['c_title_en'],
$_POST['c_description'],
$_POST['c_description_en'],
$_POST['c_date']
));
if ( $insert ){
$last_id = $db->lastInsertId();
}
}
koşulun içini istediğin gibi doldur