PDOException: SQLSTATE [HY093]

-2

These are the errors shown by

  

Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE [HY093]: Invalid parameter number: number of bound variables does not match number of tokens' in C: \ wamp \ www \ purchase order \ update.php on line 22   (!) PDOException: SQLSTATE [HY093]: Invalid parameter number: number of bound variables does not match number of tokens in C: \ wamp \ www \ purchase order \ update.php on line 22

This is the code:

<?php
require_once 'dbconfig.php';


    if($_POST)
    {
        $id = $_POST['id'];
        $emp_name = $_POST['emp_name'];
        $emp_descripcion = $_POST['emp_descripcion'];
        $emp_fecha = $_POST['emp_fecha'];
        $emp_cantidad = $_POST['emp_cantidad'];
        $emp_precio = $_POST['emp_precio'];


        $stmt = $db_con->prepare("
           UPDATE tbl_employees 
           SET emp_name=:en, 
               emp_fecha=:fe, 
               emp_cantidad:ca, 
               emp_precio:pr 
           WHERE emp_id=:id
        ");
        $stmt->bindParam(":en", $emp_name);
        $stmt->bindParam(":fe", $emp_fecha);
        $stmt->bindParam(":ca", $emp_cantidad);     
        $stmt->bindParam(":pr", $emp_precio);
        $stmt->bindParam(":id", $id);

        if($stmt->execute())
        {
            echo "Successfully updated";
        }
        else{
            echo "Query Problem";
        }
    }

?>
    
asked by Steven Rodriguez 27.12.2016 в 21:09
source

1 answer

0

In this case, you need to put 2 symbols of the same in your sentence

emp_cantidad:ca, emp_precio:pr

try changing it to:

emp_cantidad=:ca, emp_precio=:pr
    
answered by 28.12.2016 в 15:38