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条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 java在应用程序里获取不到扬声器设备
    • ¥15 echarts动画效果的问题,请帮我添加一个动画。不要机器人回答。
    • ¥60 许可证msc licensing软件报错显示已有相同版本软件,但是下一步显示无法读取日志目录。
    • ¥15 Attention is all you need 的代码运行
    • ¥15 一个服务器已经有一个系统了如果用usb再装一个系统,原来的系统会被覆盖掉吗
    • ¥15 使用esm_msa1_t12_100M_UR50S蛋白质语言模型进行零样本预测时,终端显示出了sequence handled的进度条,但是并不出结果就自动终止回到命令提示行了是怎么回事:
    • ¥15 前置放大电路与功率放大电路相连放大倍数出现问题
    • ¥30 关于<main>标签页面跳转的问题
    • ¥80 部署运行web自动化项目
    • ¥15 腾讯云如何建立同一个项目中物模型之间的联系