1

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

mysqli_stmt::bind_param():变量的数量与准备好的语句中的参数数量不匹配

下面按照我的代码:

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

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

4

1 回答 1

0

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

$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

于 2015-07-02T13:36:20.820 回答