当前位置: 首页 > 知识库问答 >
问题:

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

孙承弼
2023-03-14

我在准备好的语句(mysqli)上遇到了麻烦,我正在进行连接,一切都是正确的,直到我试图绑定参数,问题是,我试图绑定63个值,我检查了很多次我有正确的值,因为我找不到导致错误的错误:

以下是我的代码:

$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);
        }
    }

希望有人能解释我在这里失败了什么!

共有1个答案

赵昊阳
2023-03-14

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

$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(),?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");

Edit:
下次可能会对错误进行1次谷歌搜索:
Php mysqi bind_param变量数与准备好的语句中的参数数不匹配

 类似资料: