0

Im trying to get some data from my database but i get the next error: SQLSTATE[HY093]: Invalid parameter number.

My code is:


<?php

header("content-type:application/json");

include "funciones.php";

$fecha = $_REQUEST['año'];
$importe = $_REQUEST['importe'];
$npedido = $_REQUEST['numero_pedido'];

$conn = estableceConexion();

$consulta = $conn->prepare("SELECT numero_pedido, sum(importe_factura) as importe FROM pedido natural join linea_pedido where fecha_pedido LIKE ':f%' group by numero_pedido having importe>:i");
$consulta->bindParam(':f',$fecha,PDO::PARAM_STR);
$consulta->bindParam(':i',$importe,PDO::PARAM_INT);
$consulta->execute();

$filas = $consulta->fetchAll(PDO::FETCH_ASSOC);
$res = array("consulta" => $filas);
echo json_encode($res);

$conn = null;

?>

Álvaro González
  • 142,137
  • 41
  • 261
  • 360

0 Answers0