Advertisement
Guest User

Untitled

a guest
May 13th, 2016
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQL 0.57 KB | None | 0 0
  1. <?php
  2. $servername = "localhost";
  3. $username = "username";
  4. $password = "password";
  5. $dbname = "myDB";
  6.  
  7. // CREATE connection
  8. $conn = mysqli_connect($servername, $username, $password, $dbname);
  9. // CHECK connection
  10. IF (!$conn) {
  11.     die("Connection failed: " . mysqli_connect_error());
  12. }
  13.  
  14. $sql = "INSERT INTO MyGuests (firstname, lastname, email)
  15. VALUES ('John', 'Doe', 'john@example.com')";
  16.  
  17. IF (mysqli_query($conn, $sql)) {
  18.     echo "New record created successfully";
  19. } ELSE {
  20.     echo "Error: " . $sql . "<br>" . mysqli_error($conn);
  21. }
  22.  
  23. mysqli_close($conn);
  24. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement