Advertisement
Guest User

Untitled

a guest
Mar 4th, 2016
459
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.71 KB | None | 0 0
  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. </head>
  5. <body>
  6. <?php
  7. $servername = "localhost";
  8. $username = "root";
  9. $password = "mysql";
  10. $dbname = "myDB";
  11. // Create connection
  12.  
  13. $conn = mysqli_connect($servername, $username, $password, $dbname);
  14. // Check connection
  15. if (!$conn) {
  16.     die("Connection failed: " . mysqli_connect_error());
  17. }
  18.  
  19. // sql to create table
  20. $sql = "CREATE TABLE MyTable (
  21. id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  22. uname VARCHAR(30) NOT NULL,
  23. msg TINYTEXT NOT NULL,
  24. reg_date TIMESTAMP
  25. )";
  26.  
  27. if (mysqli_query($conn, $sql)) {
  28.     echo "Table MyGuests created successfully";
  29. } else {
  30.     echo "Error creating table: " . mysqli_error($conn);
  31. }
  32.  
  33. mysqli_close($conn);
  34. ?>
  35. </body>
  36. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement