dongzhan8620 2016-09-02 08:39
浏览 47
已采纳

没有错误消息,INSERT请求不起作用

I have a problem using a long INSERT request in SQL, my request were working perfectl before I updated it , but now the instruction doesn't insert anything in my database and also doesn't make any error message. Here's the code :

try
{
    /* On connecte à la base de données MySQL */
    $bdd = new PDO('mysql:host=myhost;dbname=mydbname', 'root', 'mypass');
    /* On définit la requête SQL à exécuter */
    $requeteInscription = 'INSERT INTO interventions 
                              (utilisateur_id, nom_proprietaire, 
                               num_tel_proprietaire, courriel_proprietaire, 
                               informations_bien, interet, delai,
                               plan_2D, plan_3D, visite_virtuelle, 
                               shooting_photo, annee_construction, 
                               installation_gaz, cle_agence, cave, 
                               garage, type_bien, surface, adresse) 
                      VALUES ("'.$utilisateurId.'","'.$nomProprietaire.'","'
                            .$numTelProprietaire.'","'.$courrielProprietaire.'","'
                            .$infosBien.'","'.$delai.'","'
                            .$plan2D.'","'.$plan3D.'","'.$visiteVirtuelle.'","'
                            .$shootingPhoto.'","'.$anneeConstruction.'","'
                            .$installationGaz.'","'.$cleAgence.'","'.$cave.'","'
                            .$garage.'","'.$typeBien.'","'.$surface.'","'.$adresse.'")';
    sleep(1);
    $requete = $bdd->prepare($requeteInscription);

    $requete->execute();
    echo '#1';
}
catch(PDOException $e)
{
    echo('Erreur! : '.$e->getMessage().'</br>');
    die();
}

And here is the request returned when I make an echo on requeteInscription :

INSERT INTO interventions (utilisateur_id, nom_proprietaire, num_tel_proprietaire, courriel_proprietaire, informations_bien, interet, delai, plan_2D, plan_3D, visite_virtuelle, shooting_photo, annee_construction, installation_gaz, cle_agence, cave, garage, type_bien, surface, adresse) VALUES ("5","Cyrille ","946458","hidden.email@stackoverflow.com","Local d'activité","Entre 4 et 6 jours.","Oui","Non","1","Non","1","2","0","1","1","3","123","Hdhdhd")

I don't see where the syntax error is (I guess it's a syntax error because when I do one, it never give me back an error message)

  • 写回答

1条回答 默认 最新

  • dongzhong1891 2016-09-02 09:11
    关注

    you are missing one value in insert query. Please add one more value in insert query. Remaining query is fine.

    INSERT INTO interventions (utilisateur_id, nom_proprietaire, num_tel_proprietaire, courriel_proprietaire, informations_bien, interet, delai, plan_2D, plan_3D, visite_virtuelle, shooting_photo, annee_construction, installation_gaz, cle_agence, cave, garage, type_bien, surface, adresse) VALUES ("5","Cyrille ","946458","hidden.email@stackoverflow.com","Local d'activité","Entre 4 et 6 jours.","Oui","Non","1","Non","1","2","0","1","1","3","123","Hdhdhd","");

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 怎么把多于硬盘空间放到根目录下
  • ¥15 Matlab问题解答有两个问题
  • ¥50 Oracle Kubernetes服务器集群主节点无法访问,工作节点可以访问
  • ¥15 LCD12864中文显示
  • ¥15 在使用CH341SER.EXE时不小心把所有驱动文件删除了怎么解决
  • ¥15 gsoap生成onvif框架
  • ¥15 有关sql server business intellige安装,包括SSDT、SSMS。
  • ¥15 stm32的can接口不能收发数据
  • ¥15 目标检测算法移植到arm开发板
  • ¥15 利用JD51设计温度报警系统