//index.php
if(isset($_GET["action"])){
if($_GET["action"]=="add_admin"){
require("../gbl_admin/admin_header.php");
require("../gbl_admin/admin_add.php");
}
}
//admin_header.php
require("../gbl_admin/db/db_ini.php");
require("../gbl_admin/classes/dbmgmt.php");
require("../gbl_admin/configuration/passwordhash.php");
I have created a in dbmgmt to handle database but after calling it through index.php and submitting the form it gives me "Creating default object from empty value " error as well as "Call to undefined function create_hash()" error from passwordhash.php file. This means that the files are not being loaded by index.php. How do i fix this??
我已经创建了一个dbmgmt来处理数据库,但是在通过index.php调用它并提交表单后,它给了我“从空值创建默认对象”错误以及“调用未定义函数create_hash()”错误来自passwordhash.php文件。这意味着index.php没有加载文件。我该如何解决??
1 个解决方案
#1
I would suggest you always use absolute paths by using __DIR__
, or for less than PHP 5.3, use dirname(__FILE__)
我建议你总是使用__DIR__来使用绝对路径,或者小于PHP 5.3,使用dirname(__ FILE__)
This will mean that your include should be along the lines of
这意味着你的包括应该是沿着的
require(__DIR__."/../gbl_admin/admin_header.php");
However, as you are using require, and you are saying the files are not being required, the only logical explanation is that your if condition is not being satisfied.
但是,当您使用require时,并且您说这些文件不是必需的,唯一合乎逻辑的解释是您的if条件不满足。
Try:
if(isset($_GET["action"])){
if($_GET["action"]=="add_admin"){
require("../gbl_admin/admin_header.php");
require("../gbl_admin/admin_add.php");
}else{
die('error 1');
}
}else{
die('error 2');
}
#1
I would suggest you always use absolute paths by using __DIR__
, or for less than PHP 5.3, use dirname(__FILE__)
我建议你总是使用__DIR__来使用绝对路径,或者小于PHP 5.3,使用dirname(__ FILE__)
This will mean that your include should be along the lines of
这意味着你的包括应该是沿着的
require(__DIR__."/../gbl_admin/admin_header.php");
However, as you are using require, and you are saying the files are not being required, the only logical explanation is that your if condition is not being satisfied.
但是,当您使用require时,并且您说这些文件不是必需的,唯一合乎逻辑的解释是您的if条件不满足。
Try:
if(isset($_GET["action"])){
if($_GET["action"]=="add_admin"){
require("../gbl_admin/admin_header.php");
require("../gbl_admin/admin_add.php");
}else{
die('error 1');
}
}else{
die('error 2');
}