35 lines
956 B
PHP
35 lines
956 B
PHP
<?php
|
|
|
|
class peter_db {
|
|
private $DBServer;
|
|
private $DBUser;
|
|
private $DBPass;
|
|
private $DBName;
|
|
private $conn;
|
|
|
|
// Constructor to initialize database connection variables
|
|
public function __construct() {
|
|
$this->DBServer = '192.168.1.198'; // Your DB server (example: localhost)
|
|
$this->DBUser = 'phowell'; // Your DB username
|
|
$this->DBPass = 'rolley34'; // Your DB password
|
|
$this->DBName = 'db'; // Your DB name
|
|
}
|
|
|
|
// Method to establish a database connection
|
|
public function getConnection() {
|
|
$this->conn = new mysqli($this->DBServer, $this->DBUser, $this->DBPass, $this->DBName);
|
|
|
|
// Check the connection
|
|
if ($this->conn->connect_error) {
|
|
die('Database connection failed: ' . $this->conn->connect_error);
|
|
}
|
|
|
|
// Set the character set
|
|
$this->conn->set_charset('utf8');
|
|
|
|
return $this->conn;
|
|
}
|
|
}
|
|
|
|
?>
|