php - 准备好的语句帮助,63/63 参数失败,参数数量不匹配

标签 php mysql mysqli prepared-statement bindvalue

<分区>

我在使用准备好的语句 (mysqli) 时遇到问题,我正在连接并且一切正常,直到我尝试绑定(bind)参数,这就是问题所在,我正在尝试绑定(bind) 63 个值,我确实检查了很多有时我有正确的值(value)观并感到绝望,因为我找不到导致我犯错误的错误:

mysqli_stmt::bind_param(): Number of variables doesn't match number of parameters in prepared statement

这里遵循我的代码:

$query = $db->prepare("INSERT INTO `T_TOUR_RES`(`Id`, `UpDate`, `NumVoie`, `Indice`, `Voie`, `Ville`, `CodePostal`, `LocNom`, `LocPrenom`, `LocNumVoie`, `LocIndice`, `LocVoie`, `LocCodePostal`, `LocVille`, `LocTel`, `PropNom`, `PropPrenom`, `PropNumVoie`, `PropIndice`, `PropVoie`, `PropVille`, `PropCodePostal`, `PropTel`, `EntRaisonSociale`, `EntDenominationCommerciale`, `EntTypeEntreprise`, `EntNumVoie`, `EntIndice`, `EntVoie`, `EntVille`, `EntCodePostal`, `EntTel`, `EntAPE`, `EntNAF`, `EntSIRET`, `IsLoc`, `IsProp`, `IsPro`, `IsAdmin`, `Done`, `DoneDate`, `DoneEq`, `IsIndiv`, `IsCollectif`, `NbOccupants`, `HasComposteur`, `IsPrincipal`, `IsSecondaire`, `IsGite`, `IsHote`, `IsRefus`, `IsWeb`, `HasPlace`, `IsDiffManip`, `IsPrecoPAV`, `LinkCollectif`, `IsBatimentCollectif`, `HaveBac`, `NbOM`, `NbTri`, `Comportement`, `Remarque`, `RecapBac`, `ID_TOUR`, `ID_SOURCE`) VALUES (NULL, NOW(),'?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?')");

    if ($query === FALSE) {
        die ("Mysql Error: " . $db->error);
    } else {
        if ($query->bind_param("issssssisssssssissssssssissssssssiiiiissiiiiiiiiiiiiiiiiiisssii",$this->NumVoie, $this->Indice, $this->Voie, $this->Ville, $this->CodePostal, $this->LocNom, $this->LocPrenom, $this->LocNumVoie, $this->LocIndice, $this->LocVoie, $this->LocCodePostal, $this->LocVille, $this->LocTel, $this->PropNom, $this->PropPrenom, $this->PropNumVoie, $this->PropIndice, $this->PropVoie, $this->PropVille, $this->PropCodePostal, $this->PropTel, $this->EntRaisonSociale, $this->EntDenominationCommerciale, $this->EntTypeEntreprise, $this->EntNumVoie, $this->EntIndice, $this->EntVoie, $this->EntVille, $this->EntCodePostal, $this->EntTel, $this->EntAPE, $this->EntNAF, $this->EntSIRET, $this->IsLoc, $this->IsProp, $this->IsPro, $this->IsAdmin, $this->done, $this->DoneDate, $this->DoneEq, $this->IsIndiv, $this->IsCollectif, $this->NbOccupants, $this->HasComposteur, $this->IsPrincipal, $this->IsSecondaire, $this->IsGite, $this->IsHote, $this->IsRefus, $this->IsWeb, $this->HasPlace, $this->IsDiffManip, $this->IsPrecoPAV, $this->LinkCollectif, $this->IsBatimentCollectif, $this->HaveBac, $this->NbOM, $this->NbTri, $this->Comportement, $this->Remarque, $this->RecapBac, $this->ID_TOUR, $this->ID_SOURCE)) {

            if($query->execute()){}else{die ("Mysql Error: " . $db->error);}
        } else { 
            die ("Mysql Error: " . $db->error);
        }
    }

希望有人能解释我在这里失败的原因!

最佳答案

如果你使用的是准备好的语句,你不应该在你的周围使用单引号?

$query = $db->prepare("INSERT INTO `T_TOUR_RES`(`Id`, `UpDate`, `NumVoie`, `Indice`, `Voie`, `Ville`, `CodePostal`, `LocNom`, `LocPrenom`, `LocNumVoie`, `LocIndice`, `LocVoie`, `LocCodePostal`, `LocVille`, `LocTel`, `PropNom`, `PropPrenom`, `PropNumVoie`, `PropIndice`, `PropVoie`, `PropVille`, `PropCodePostal`, `PropTel`, `EntRaisonSociale`, `EntDenominationCommerciale`, `EntTypeEntreprise`, `EntNumVoie`, `EntIndice`, `EntVoie`, `EntVille`, `EntCodePostal`, `EntTel`, `EntAPE`, `EntNAF`, `EntSIRET`, `IsLoc`, `IsProp`, `IsPro`, `IsAdmin`, `Done`, `DoneDate`, `DoneEq`, `IsIndiv`, `IsCollectif`, `NbOccupants`, `HasComposteur`, `IsPrincipal`, `IsSecondaire`, `IsGite`, `IsHote`, `IsRefus`, `IsWeb`, `HasPlace`, `IsDiffManip`, `IsPrecoPAV`, `LinkCollectif`, `IsBatimentCollectif`, `HaveBac`, `NbOM`, `NbTri`, `Comportement`, `Remarque`, `RecapBac`, `ID_TOUR`, `ID_SOURCE`) VALUES (NULL, NOW(),?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");

编辑:
下次也许对错误进行 1 次谷歌搜索:
Php mysqi bind_param Number of variables doesn't match number of parameters in prepared statement

关于php - 准备好的语句帮助,63/63 参数失败,参数数量不匹配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31186009/

相关文章:

php - PHP 中的 mysql_query 包含返回 mysql 错误的变量

PHP 查找最接近时间线周期的日期

mysql - Spring Boot JPA 从缓存

php - 注册或登录表 fatal error

javascript - 使用 ajax/Javascript 动态验证用户选择

php - while 循环仅返回 1 个产品行

php - Ajax请求导致服务器崩溃

php - 如何从 Laravel 5 的内核中删除旧的 artisan 命令

PHP:Facebook/Twitter 集成

mysql - 创建批处理文件循环并根据用户输入重新启动