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 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测