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 shape_predictor_68_face_landmarks.dat
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制