Añadir actor a película


$server = "localhost";
$user = "root";
$password = "";
$db = "sakila";
try {
    $conn = new PDO("mysql:host=$server;dbname=$db;charset=UTF8", $user, $password);
    $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    //Los datos que tengo que insertar
  
    $nombre = "VIVIEN";
    $apellidos = "BERGEN";
    $pelicula="ACADEMY DINOSAUR";
    
    $sql="SELECT * FROM actor where first_name=:first_name and last_name=:last_name";
    $parametros=[
        'first_name'=>$nombre,
        'last_name'=>$apellidos
    ];
    
    $st=$conn->prepare($sql);
    $st->execute($parametros);
    $actor=$st->fetch();
    $actor_id=$actor['actor_id'];
    echo $actor_id;
    
     $sql="SELECT * FROM film where title=:title";
    $parametros=[
        'title'=>$pelicula
    ];
    
    $st=$conn->prepare($sql);
    $st->execute($parametros);
    $film=$st->fetch();
    $film_id=$film['film_id'];
    echo $film_id;
    
    $sql="insert into film_actor(film_id,actor_id) values (:film_id,:actor_id)";
     $parametros=[
        'film_id'=>$film_id,
        'actor_id'=>$actor_id,
    ];
    $st=$conn->prepare($sql);
    $st->execute($parametros);
} catch (Exception $e) {
    echo "Connection failed: " . $e->getMessage();
}