Advertisement
Guest User

Untitled

a guest
Apr 13th, 2016
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. <?php
  2. //CREATE CONNECTION
  3. $servername = "localhost";
  4. $username = "root";
  5. $password = "root";
  6. $conn = new mysqli($servername, $username, $password);
  7. // CHECK THE CONNECTION
  8. if ($conn->connect_error) {
  9. die("Connection failed: " . $conn->connect_error);
  10. }
  11. // CREATE ESTATE AGENTS DATABASE
  12. $sql = "CREATE DATABASE IF NOT EXISTS estate_agents";
  13. if ($conn->query($sql) === TRUE) {
  14. $dbname= "estate_agents";
  15. $newConnection = new mysqli($servername, $username, $password,$dbname);
  16. //CREATE PROPERTIES TABLE
  17. $sql = "CREATE TABLE IF NOT EXISTS properties (
  18. property_id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  19. property_name VARCHAR(50) NOT NULL,
  20. property_cost VARCHAR(50) NOT NULL,
  21. property_description VARCHAR(500) NOT NULL
  22. )";
  23. if ( $newConnection->query($sql) === TRUE) {
  24. }
  25. else {
  26. echo "Error creating table: " . $newConnection->error . "</br>";
  27. }
  28. }
  29. else {
  30. echo "estate_agents not functional: " . $newConnection->error . "</br>";
  31. }
  32. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement