Warning: PDOStatement :: execute (): SQLSTATE [HY093]: Invalid parameter number: parameter was not defined

0

I get that error

  

Warning: PDOStatement :: execute (): SQLSTATE [HY093]: Invalid parameter number: parameter was not defined in C: \ xampp \ htdocs \ Practical1 \ practices \ blog \ admin \ edit.php on line 45

I check line 45 and I really do not know what you have, this is the code;

<?php session_start();
require "config.php";
require "../funciones.php";

comprobar_session();

$conexion = conexion($bd_config);
verificar_conexion($conexion);

$id = (int)$_GET['id'];

$posts = obtener_post_por_id($conexion, $id);
$posts = $posts[0];

if(empty($id)){
    header('Location:'.RUTA.'admin');
}
if(!$posts){
header('Location'.RUTA.'admin');    
}

//PENDIENTE DE MODIFICACION 
if($_SERVER['REQUEST_METHOD'] == 'POST'){

    $titulo = $_POST['titulo'];
    $extracto = $_POST['extracto'];
    $texto = $_POST['texto'];
    $id2 = $_POST['id'];
    $thumb_guardada = $_POST['thumb_guardada'];
    $thumb = $_FILES['thumb'];

    if(empty($thumb['name'])){

        $thumb = $thumb_guardada;
    } else {

        $archivo_subido = '../'.$blog_config['carpeta_imagenes'].'/'.$_FILES['thumb']['name'];
        move_uploaded_file($_FILES['thumb']['tmp_name'], $archivo_subido);
        $thumb = $_FILES['thumb']['name'];
    }
    $actualizar_db = $conexion->prepare('UPDATE articulos SET titulo = :titulo, extractor = :extractor, texto = :texto, thumb = :thumb WHERE id = :id');
    $actualizar_db->execute(array(

        ':titulo' => $titulo,
        ':extracto' => $extracto,
        ':texto' => $texto,
        ':thumb' => $thumb,
        ':id' => $id2 //linea 45

    ));
    header('Location: '.RUTA.'admin');
}



require "../view/admin_editar.view.php";
?>
    
asked by JOSE HERRADA 29.05.2018 в 19:17
source

1 answer

1

The problem is that in your query you have the parameter as extractor and in the execute you have extracto . Just add the execute r and it will work.

$actualizar_db = $conexion->prepare('UPDATE articulos SET titulo = :titulo, extractor = :extractor, texto = :texto, thumb = :thumb WHERE id = :id');
$actualizar_db->execute(array(

    ':titulo' => $titulo,
    ':extractor' => $extracto,
    ':texto' => $texto,
    ':thumb' => $thumb,
    ':id' => $id2 //linea 45

));
    
answered by 29.05.2018 в 19:23