Advertisement
Guest User

Untitled

a guest
Mar 30th, 2018
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.03 KB | None | 0 0
  1. <?php
  2.  
  3. error_reporting(E_ALL);
  4. ini_set('display_errors', 1);
  5.  
  6. $server = 'localhost';
  7. $username = 'root';
  8. $password = '';
  9. $db = 'statusDB';
  10.  
  11. try {
  12.   $connection = new mysqli($server, $username, $password);
  13.  
  14.   if ($connection->connect_error) {
  15.     throw new Exception('booboo 1');
  16.   }
  17.  
  18.   $q = 'CREATE DATABASE IF NOT EXISTS ' . $db;
  19.  
  20.   if (!$connection->query($q)) {
  21.     throw new Exception('booboo 2');
  22.   }
  23.  
  24.   if (!$connection->select_db($db)) {
  25.     throw new Exception('booboo 3');
  26.   }
  27.  
  28.   $q2 = 'CREATE TABLE IF NOT EXISTS status (
  29.    code INT(4) AUTO_INCREMENT PRIMARY KEY NOT NULL,
  30.    date DATE NOT NULL,
  31.    status VARCHAR(512) NOT NULL,
  32.    sharePublic BOOLEAN,
  33.    shareFriends BOOLEAN,
  34.    shareMe BOOLEAN,
  35.    allowLike BOOLEAN,
  36.    allowComment BOOLEAN,
  37.    allowShare BOOLEAN)';
  38.  
  39.   if (!$connection->query($q2)) {
  40.     throw new Exception('booboo 4');
  41.   }
  42.  
  43.   print "weeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee\n";
  44. } catch(Exception $e) {
  45.   printf("i made a booboo: %s\n", $e->getMessage());
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement