Merhabalar, php pdo ile slider görsellerini çoklu olarak insert etmeye çalışıyorum ama bir türlü insert atmıyor hata da vermiyor acaba nerede hata yapıyorum.
Yapmak istediğim olayı daha iyi anlatmak için görsel ekliyorum.

file pond js kütüphanesini kullanarak inputlara multiple vererek birden fazla görsel ekliyorum

insert edecek dosya



<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
require '../config.php';
try {
  if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    // Assuming the product_id is passed in the form
    $product_id = $_POST['product_id'];
    // Define target directory
    $target_dir = "../../uploads/";
    // Handling multiple images for productSlider
    if (isset($_FILES['productSlider']['tmp_name']) && is_array($_FILES['productSlider']['tmp_name'])) {
        $total = count($_FILES['productSlider']['tmp_name']);
        for( $i=0 ; $i < $total ; $i++ ) {
          if ($_FILES['productSlider']['error'][$i] === UPLOAD_ERR_OK && is_uploaded_file($_FILES['productSlider']['tmp_name'][$i])) {
            $filename = 'product_' . rand(1000, 9999) . '.' . pathinfo($_FILES['productSlider']['name'][$i], PATHINFO_EXTENSION);
            move_uploaded_file( $_FILES['productSlider']['tmp_name'][$i], $target_dir . $filename );
            // Insert file name into the product_slider table with the corresponding product id
            $sql = "INSERT INTO product_slider (product_id, imgpath, position) VALUES (?, ?, ?)";
            $stmt = $pdo->prepare($sql);
            $stmt->execute([$product_id, $filename, 1]);
            } else {
            echo "Error occurred while uploading file: " . $_FILES['productSlider']['error'][$i];
          }
        }
    }
    // Handling multiple images for productSliderSecond
    if (isset($_FILES['productSliderSecond']['tmp_name']) && is_array($_FILES['productSliderSecond']['tmp_name'])) {
        $totalSecond = count($_FILES['productSliderSecond']['tmp_name']);
        for( $i=0 ; $i < $totalSecond ; $i++ ) {
          if (is_uploaded_file($_FILES['productSliderSecond']['tmp_name'][$i])) {
            $filename = 'product_' . rand(1000, 9999) . '.' . pathinfo($_FILES['productSliderSecond']['name'][$i], PATHINFO_EXTENSION);
            move_uploaded_file( $_FILES['productSliderSecond']['tmp_name'][$i], $target_dir . $filename );
            // Insert file name into the product_slider table with the corresponding product id
            $sql = "INSERT INTO product_slider (product_id, imgpath, position) VALUES (?, ?, ?)";
            $stmt = $pdo->prepare($sql);
            $stmt->execute([$product_id, $filename, 2]);
          } else {
            echo "Error occurred while uploading file: " . $_FILES['productSlider']['error'][$i];
          }
        }
    }
  }
  }
    catch (PDOException $e) {
      echo "Error: " . $e->getMessage();
  }
?>