Php PDO中的参数号无效

Here is my php code

$data=array(
        'title'=>$_POST['title'],
        'description'=>$_POST['description'],
        'image_path'=>$filepath
    );
    print_r($data);
    $result=$connect->prepare("INSERT INTO `mir_news`(`title`,`description`,`image_path`) VALUES (?,?,?)");
    $result->execute($data);

I am getting this error

Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY093]: Invalid parameter number: parameter was not defined' in C:\xampp\htdocs\miradmin\views\add_news.php:24 Stack trace: #0 C:\xampp\htdocs\miradmin\views\add_news.php(24): PDOStatement->execute(Array) #1 C:\xampp\htdocs\miradmin\index.php(46): require('C:\xampp\htdocs...') #2 {main} thrown in C:\xampp\htdocs\miradmin\views\add_news.php on line 24

print_r($data) will be fine.

You only want the values of the array, not the keys:

$result->execute(array_values($data));

Alternatively, define them differently earlier:

$data = array($_POST["title"], $_POST["description"], $filepath);
//...
$result->execute($data);

Try array_values while passing $data

$result->execute(array_values($data)); $result->execute($data);

array_values() returns all the values from the array and indexes the array numerically.

Try to look in the variable "$filepath" where the value comes from?