Advertisement
nicolas-chuet

modal_bdd.php

Apr 1st, 2020
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.05 KB | None | 0 0
  1. <?php try { $bdd = new PDO('mysql:host=localhost;dbname=base_test_modal;charset=utf8', 'root', ''); $bdd->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } catch (Exception $e) { echo "erreur"; } $texteBody = $bdd->query('SELECT `texte_modal` FROM `url_modal` WHERE `url` = $_SERVER["HTTP_REFERER"]') ?>
  2. <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModalCenter">Launch demo modal</button>
  3. <div class="modal fade" id="exampleModalCenter" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true"><div class="modal-dialog modal-dialog-centered" role="document"><div class="modal-content"><div class="modal-header"><h5 class="modal-title" id="exampleModalLongTitle">Modal Title</h5><button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button></div><div class="modal-body"><?php echo $texteBody; ?></div><div class="modal-footer"><button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button></div></div></div>
  4. /********************************************************************/
  5. /*l 'equivalent de la premier ligne est :
  6. <?php
  7. try
  8. {
  9. $bdd = new PDO('mysql:host=localhost;dbname=base_test_modal;charset=utf8', 'root', '');
  10. $bdd->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  11. }
  12. catch (Exception $e)
  13. {
  14. echo "erreur";
  15. }
  16. $texteBody = $bdd->query('SELECT `texte_modal` FROM `url_modal` WHERE `url` = $_SERVER["HTTP_REFERER"]')
  17. ?>
  18.  
  19. cela produit la fatal error suivante
  20. Fatal error: Uncaught PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '["HTTP_REFERER"]' at line 1 in C:\Formation\givexpert\sitestest\modal\modal.php:1 Stack trace: #0 C:\Formation\givexpert\sitestest\modal\modal.php(1): PDO->query('SELECT `texte_m...') #1 {main} thrown in C:\Formation\givexpert\sitestest\modal\modal.php on line 1
  21. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement