douzhaishan5462 2017-01-14 05:08
浏览 136

SQLSTATE [HY093]:参数号无效:绑定变量数与行中的令牌数不匹配

error_reporting( ~E_NOTICE );

require_once 'includes/connect5.php';

if(isset($_POST['btnsave']))
{
$reserveBy = $_POST['reserveBy'];
$bookId = $_POST['bookId'];// isbn
$bookTitle = $_POST['bookTitle'];// book name
$dateReserve = $_POST['dateReserve'];
if(empty($reserveBy)){
        $errMSG = "Please Enter Name.";
    }
else if(empty($bookId)){
        $errMSG = "Please Enter the BOok ISBN.";
    }
else if(empty($bookTitle)){
        $errMSG = "Please Enter the Title.";
    }
else
    {
        $stmt = $DB_con->prepare("INSERT INTO reservation(reserveBy,bookId,bookTitle,dateReserve,reserveExp) VALUES(:rrb, :risbn, :rbtit, now(), now() + INTERVAL 3 HOUR)");
        $stmt->bindParam(':rrb',$reserveBy);
        $stmt->bindParam(':risbn',$bookId);
        $stmt->bindParam(':rbtit',$bookTitle);

if($stmt->execute()) // this is the error line it points to this
        {
            $successMSG = "New Record Successfully Inserted ...";
            header("refresh:1;index1.php"); // redirects image view page after a seconds.
        }
        else
        {
            $errMSG = "error while inserting....";
        }
    }
}
?>

I dont know why and how is has produced an error! It's pointing to the line:

if($stmt->execute())

It says:

Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens' in !

I dont understand why is it says number of bound variable does not match number of tokens even my input data is complete. I've searchd it to the internet but no one is similar to my problem.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 求daily translation(DT)偏差订正方法的代码
    • ¥15 js调用html页面需要隐藏某个按钮
    • ¥15 ads仿真结果在圆图上是怎么读数的
    • ¥20 Cotex M3的调试和程序执行方式是什么样的?
    • ¥20 java项目连接sqlserver时报ssl相关错误
    • ¥15 一道python难题3
    • ¥15 牛顿斯科特系数表表示
    • ¥15 arduino 步进电机
    • ¥20 程序进入HardFault_Handler
    • ¥15 关于#python#的问题:自动化测试