dsfs504545 2015-09-11 12:12
浏览 34
已采纳

SQL:查询有效,但出错了吗?

The query works, but I get an error trying to see the error but it can not. All variable get "value='1' " when marked....

$tuning = SESSION['tuning']));
$garanciq = (!empty($_SESSION['garanciq']));
$avtopilot = (!empty($_SESSION['avtopilot'])); 
$servo = (!empty($_SESSION['servo']));   
$tiptronik = (!empty($_SESSION['tiptronik']));
$servo = (!empty($_SESSION['servo']));
$service = (!empty($_SESSION['service']));
$bord = (!empty($_SESSION['bord']));
$navi = (!empty($_SESSION['navi']));
$volan = (!empty($_SESSION['volan']));  
$zastrahovka = (!empty($_SESSION['zastrahovka']));    

$iInsert= new general();
$iInsert->query("INSERT INTO  other_checkbox 
                 (tuning, garanciq, avtopilot, servo, tiptronik,
                  bord_komp, serviz_knijka, navig_sistema, desen_volan, 
                  zastrahovka) 
                 VALUES " . "(:tuning, :garanciq, avtopilot, :servo, 
                              :tiptronik, :bord, :serviceBook, :navi, 
                              :volan, :zastrahovka)");

$iInsert->bind(':tuning', $tuning);
$iInsert->bind(':garanciq', $garanciq);
$iInsert->bind(':avtopilot', $avtopilot);
$iInsert->bind(':servo', $servo);
$iInsert->bind(':tiptronik', $tiptronik);
$iInsert->bind(':bord', $bord);
$iInsert->bind(':serviceBook', $service);
$iInsert->bind(':navi', $navi);
$iInsert->bind(':volan', $volan);
$iInsert->bind(':zastrahovka', $zastrahovka);
$iInsert->execute();
$iInsert->debugDumpParams(); ->get error, but have Fatal Error !
$insert_other_chek = $iInsert->lastInsertId();->get LastInsertId

I get this error

Warning: PDOStatement::execute(): SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens in C:\xampp\htdocs\test\ClassGeneral.php on line 45

Fatal error: Call to undefined method general::debugDumpParams() in C:\xampp\htdocs\test\publicFinish.php on line 165

This is my class General !

class general {

    private $db;
    private $stmt;

    public function __construct() {
        $this->db = new connect();
        $this->db = $this->db->connectDb();
    }
    public function query($sql) {
        $this->stmt = $this->db->prepare($sql);
    }  
    public function execute() {
        return $this->stmt->execute();
    }    
}
  • 写回答

4条回答 默认 最新

  • douchi1945 2015-09-11 12:21
    关注

    replace

    avtopilot
    

    with

    :avtopilot
    

    in query

    $iInsert->query("
        INSERT INTO  other_checkbox 
            (tuning, garanciq, avtopilot, servo, tiptronik, bord_komp, serviz_knijka, navig_sistema, desen_volan, zastrahovka) 
        VALUES
            (:tuning, :garanciq, :avtopilot, :servo, :tiptronik, :bord, :serviceBook, :navi, :volan, :zastrahovka)
    ");
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 ATAC测序到底用什么peak文件做Diffbind差异分析
  • ¥15 安装ubantu过程中第一个vfat 文件挂载失败
  • ¥20 GZ::CTF如何兼容一些靶机?
  • ¥15 etcd集群部署问题
  • ¥20 谁可以帮我一下问一下各位
  • ¥15 为何重叠加权后love图的SMD与svyCreateTableOne函数绘制基线表的不一致
  • ¥15 QFILHelper怎么恢复全字库,提示进程已完成,只能恢复分区文件
  • ¥20 你好,我想问下easyExcel下拉多选,或者复选框可以实现吗
  • ¥20 双非跨考工科哪个专业和方向就业前景好?
  • ¥20 求会6sv辐射传输模型,辅导(可py6s🙏🏻有偿