namespace misql;
class m_ {
function localhost()
{
return 'localhost';
}
}
class DB{
private $dbHost = "localhost";
private $dbUsername = "user72751_sovaov";
private $dbPassword = "pe456ISgaR";
private $dbName = "user72751_sovaov";
public function __construct(){
if(!$this->db){
// Connect to the database
$conn = new mysqli($this->dbHost, $this->dbUsername, $this->dbPassword, $this->dbName);
if($conn->connect_error){
die("Failed to connect with MySQL: " . $conn->connect_error);
}else{
$this->db = $conn;
}
}
}
.....
define("dbHost","localhost");
define("dbUsername","user72751_sovaov");
define("dbPassword","passwd");
define("dbName","user72751_sovaov");
include_once 'Первый_файл_с_перемнными.php';
class DB{
private $dbHost ='Localhost';
private $dbUsername = "user72751_sovaov";
private $dbPassword = "passwd";
private $dbName = "user72751_sovaov";
public function __construct()
{
if(!$this->db){
// Connect to the database
$conn = new mysqli($this->dbHost, $this->dbUsername, $this->dbPassword, $this->dbName);
if($conn->connect_error){
die("Failed to connect with MySQL: " . $conn->connect_error);
}else{
$this->db = $conn;
}
}
}
class DB{
private $dbHost = dbHost;
private $dbUsername = dbUsername;
private $dbPassword = dbPassword;
private $dbName = dbName;
define("dbHost","localhost");
define("dbUsername","user72751_sovaov");
define("dbPassword","******");
define("dbName","user72751_sovaov");
class DB{
private $dbHost = 'localhost';
private $dbUsername = "user72751_sovaov";
private $dbPassword = "****";
private $dbName = "user72751_sovaov";
public function __construct()
{
if(!$this->db){
// Connect to the database
$conn = new mysqli($this->dbHost, $this->dbName, $this->dbPassword, $this->dbName);
if($conn->connect_error){
die("Failed to connect with MySQL: " . $conn->connect_error);
}else{
$this->db = $conn;
}
}
}
class DBmysql {
public static function LocalHost()
{
return 'localhost';
}
public static function BDUsername()
{
return 'user72751_sovaov';
}
public static function passwd()
{
return '*****';
}
}
include_once 'Второй_файл.php';
class DB{
function Local()
{
$dbHost = DBmysql::LocalHost();
$dbUsername = DBmysqlB::BDUsername();
$dbPassword = DBmysql::passwd();
}
#private $dbHost = 'localhost';
# private $dbUsername = "user72751_sovaov";
#private $dbPassword = "****";
private $dbName = "user72751_sovaov";
public function __construct()
{
if(!$this->db){
// Connect to the database
$conn = new mysqli($this->dbHost, $this->dbUsername, $this->dbPassword, $this->dbName);
if($conn->connect_error){
die("Failed to connect with MySQL: " . $conn->connect_error);
}else{
$this->db = $conn;
}
}
}
return [
'host' => 'localhost',
'db_name' => 'user72751_sovaov',
'username' => 'user72751_sovaov',
'password' => '*******'
];
class DB {
private $config = null;
public function __construct()
{
if(file_exists('/config_bd.php')) {
$this->config = required_once './config_bd.php';
if(is_array($this->config)) {
$conn = new mysqli($this->config['db_name'],
$this->config['username'],
$this->config['password'],
$this->config['host']);
if($conn->connect_error) {
throw new Exception('Нет соедение с БД '.$conn->connect_error);
}
return $conn;
} else {
throw new Exception('Файл конфигураии БД не найден ');
}
}
}
}
// добавляем в начало индексного файла
ini_set('error_reporting', E_ALL);
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
echo "нихрена не подключилось?";
class DBmysql {
public static function LocalHost()
{
return 'localhost';
}
public static function BDUsername()
{
return 'user72751_sovaov';
}
public static function passwd()
{
return '*****';
}
}
echo "нихрена не подключилось";
define("dbHost","localhost");
define("dbUsername","user72751_sovaov");
define("dbPassword","passwd");
define("dbName","user72751_sovaov");
include_once 'Первый_файл_с_перемнными.php';
class DB{
private $dbHost ='Localhost';
private $dbUsername = "user72751_sovaov";
private $dbPassword = "passwd";
private $dbName = "user72751_sovaov";
public function __construct()
{
if(!$this->db){
// Connect to the database
$conn = new mysqli($this->dbHost, $this->dbUsername, $this->dbPassword, $this->dbName);
if($conn->connect_error){
die("Failed to connect with MySQL: " . $conn->connect_error);
}else{
$this->db = $conn;
}
}
}