Advertisement
Guest User

Untitled

a guest
Oct 18th, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.64 KB | None | 0 0
  1.         <?php
  2. $host = "localhost";
  3. $userName = "simon";
  4. $password = "simonsimon";
  5. $dbName = "test";
  6.  
  7. // Create database connection
  8. $conn = new mysqli($host, $userName, $password, $dbName);
  9.  
  10. // Check connection
  11. if ($conn->connect_error) {
  12. die("Connection failed: " . $conn->connect_error);
  13. }
  14. $json = '{"a":1,"b":2,"c":3,"d":4,"e":5}';
  15. var_dump(json_decode($json));
  16. $sql = "INSERT INTO Reservation(firstname, lastname, email)
  17. VALUES ('John', 'Doe', 'john@example.com')";
  18.  
  19. if ($conn->query($sql) === TRUE) {
  20.     echo "New record created successfully";
  21. } else {
  22.     echo "Error: " . $sql . "<br>" . $conn->error;
  23. }
  24.  
  25. $conn->close();
  26. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement