Blame view

htdocs/documents/include/DB_Connect.php 687 Bytes
c10d2abc   rcavalie   ajout fichiers se...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
  <?php
  
  /**
   * Database config variables
   */
  define("DB_HOST", "localhost");
  define("DB_USER", "root");
  define("DB_PASSWORD", "");
  define("DB_DATABASE", "login");
  
  class DB_Connect {
      private $conn;
  
      // Connecting to database
      public function connect() {
          
          // Connecting to mysql database
          $this->conn = new mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_DATABASE);
  		
  		// Check for database connection error
          if (mysqli_connect_errno()) {
              echo "Failed to connect to MySQL: " . mysqli_connect_error();
          }
          // return database handler
          return $this->conn;
      }
  }
  
  $db = new Db_Connect();
  $this->conn = $db->connect();
  
  ?>