[英]Warning: require_once(../initialize.php): failed to open stream and Fatal error: require_once(): Failed opening required problem
我正在将我的系统运行到 000webhost,当我打开它时会弹出这个问题
警告:require_once(../initialize.php):无法打开 stream:/storage/ssd4/040/17993040/public_html/EPS/classes/DBConnection.php 行中没有这样的文件或目录
致命错误:require_once():在 /storage/ssd4/040/17993040/public_html 中打开所需的 '../initialize.php' (include_path='.:/usr/share/pear:/usr/share/php') 失败/EPS/classes/DBConnection.php 在第 3 行
这是代码文件
DBConnection.php
<?php
if(!defined('id17993040_epsdb')){
require_once("../initialize.php");
}
class DBConnection{
private $host = "local_host";
private $username = "id17993040_root";
private $password = "********";
private $database = "id17993040_epsdb";
public $conn;
public function __construct(){
if (!isset($this->conn)) {
$this->conn = new mysqli($this->host, $this->username, $this->password, $this->database);
if (!$this->conn) {
echo 'Cannot connect to database server';
exit;
}
}
}
public function __destruct(){
$this->conn->close();
}
}
?>
初始化.php
<?php
$dev_data = array('id'=>'-1','firstname'=>'Developer','lastname'=>'','username'=>'dev_oretnom','password'=>'**********','last_login'=>'','date_updated'=>'','date_added'=>'');
if(!defined('base_url')) define('base_url','https://web-silverconcha.000webhostapp.com/EPS/');
if(!defined('base_app')) define('base_app', str_replace('\\','/',__DIR__).'/' );
if(!defined('dev_data')) define('dev_data',$dev_data);
if(!defined('DB_SERVER')) define('DB_SERVER',"localhost");
if(!defined('DB_USERNAME')) define('DB_USERNAME',"id17993040_root");
if(!defined('DB_PASSWORD')) define('DB_PASSWORD',"************");
if(!defined('DB_NAME')) define('DB_NAME',"id17993040_epsdb");
?>
有什么解决方案? 很抱歉只问一个新手
更新:这是文件系统文件目录
PHP 在您使用require_once()并且找不到文件时会引发致命错误,这会导致脚本停止,这与include_once()不同,它只会向您显示找不到文件的警告。
所以它只是告诉你“我在第 3 行找不到你要求的文件”
你可以试试
$realPath = realpath($_SERVER["DOCUMENT_ROOT"]);
require_once("$realPath/initialize.php");
强烈建议阅读并了解有关这些的更多信息:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.