getting database configuration into an external file
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
dbconf.php
|
||||||
15
class.php
15
class.php
@@ -2,14 +2,19 @@
|
|||||||
|
|
||||||
class ps4 {
|
class ps4 {
|
||||||
|
|
||||||
|
public function dbconf() {
|
||||||
|
global $dbconf;
|
||||||
|
$dbconf = require "dbconf.php";
|
||||||
|
return $dbconf;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
function mysql_conn($sql=null) {
|
function mysql_conn($sql=null) {
|
||||||
$servername = "10.99.0.1";
|
|
||||||
$username = "ps4";
|
$db = $this->dbconf();
|
||||||
$password = "zpmAeh9cXM7xyFR";
|
|
||||||
$dbname = "ps4";
|
|
||||||
|
|
||||||
// Create connection
|
// Create connection
|
||||||
$conn = new mysqli($servername, $username, $password, $dbname);
|
$conn = new mysqli($db["servername"], $db["username"], $db["password"], $db["dbname"]);
|
||||||
$conn->set_charset("utf8");
|
$conn->set_charset("utf8");
|
||||||
// Check connection
|
// Check connection
|
||||||
if ($conn->connect_error) {
|
if ($conn->connect_error) {
|
||||||
|
|||||||
8
dbconf.php.sample.php
Normal file
8
dbconf.php.sample.php
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<?php
|
||||||
|
return array (
|
||||||
|
'servername' => 'localhost',
|
||||||
|
'username' => 'username',
|
||||||
|
'password' => 'password',
|
||||||
|
'dbname' => 'database'
|
||||||
|
);
|
||||||
|
?>
|
||||||
Reference in New Issue
Block a user