Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?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"]') ?>
- <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModalCenter">Launch demo modal</button>
- <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">×</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>
- /********************************************************************/
- /*l 'equivalent de la premier ligne est :
- <?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"]')
- ?>
- cela produit la fatal error suivante
- 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
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement