Advertisement
Guest User

bdd

a guest
Feb 7th, 2018
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. <?php
  2. $servername = "localhost";
  3. $username = "root";
  4. $password = "";
  5. $dbname = "2msa";
  6.  
  7. try {
  8. $conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
  9. // set the PDO error mode to exception
  10. $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  11. $sql = "INSERT INTO table (NAME, PING, EVENT1, EVENT2, EVENT3, EVENT4, EVENT5)
  12. VALUES ('Jean', '250', 'rfreferf', 'ferf', 'g', 'hrth', 'kuiyu')";
  13. // use exec() because no results are returned
  14. $conn->exec($sql);
  15. echo "New record created successfully";
  16. }
  17. catch(PDOException $e)
  18. {
  19. echo $sql . "<br>" . $e->getMessage();
  20. }
  21.  
  22. $conn = null;
  23. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement