DbConnect.php
<?php
/**
* Handling database connection
*/
include_once ('Config.php');
class DbConnect {
private $conn;
function __construct() {
}
/**
* Establishing database connection
* @return database connection handler
*/
function connect() {
// Connecting to mysql database
$this->conn = new mysqli_connect(DB_HOST, DB_USERNAME, DB_PASSWORD, DB_NAME);
// Check for database connection error
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
exit;
}
// returing connection resource
return $this->conn;
}
}
class DbHandler {
private $conn;
function __construct() {
// opening db connection
$db = new DbConnect();
$this->conn = $db->connect();
}}
?>
config.php
<?php
/**
* Database configuration
*/
define('DB_USERNAME', 'medma');
define('DB_PASSWORD', 'medma');
define('DB_HOST', 'localhost');
define('DB_NAME', 'medma_sameer');
/**
* MSG91 configuration
*/
define('MSG91_AUTH_KEY', "130558AmTMgKzL582187bb");
// sender id should 6 character long
define('MSG91_SENDER_ID', 'MEDMA1');
define('USER_CREATED_SUCCESSFULLY', 0);
define('USER_CREATE_FAILED', 1);
define('USER_ALREADY_EXISTED', 2);
?>
請告訴我,可能是什麼問題,但我已經Not able to hit api to verify otp (Used Volley) 之前發佈,但是當我開始測試在那裏我安裝我被困在我的本地文件夾中每個PHP文件與極第一步是數據庫連接我上面寫的代碼並不顯示除空白我不能使用PHP連接到我的本地
可否請你嘗試加入127.0.0.1而不是本地主機進入配置?還有什麼是錯誤信息?添加調試到您的PHP代碼http://stackoverflow.com/questions/845021/how-to-get-useful-error-messages-in-php所以你可以看到在瀏覽器中的錯誤信息 – hmrc87
添加'error_reporting(E_ALL) ; ini_set('display_errors',1);'在頂部,然後看輸出是什麼 – Peon