我从一个开发人员那里继承了一个站点,他们使用以下函数为我假设的站点设置文档根目录和定义mysql_connection:
function construct()
{
$this->mysql_link = mysql_connect("the_host", "username", "password");
mysql_select_db("thedatabase", $this->mysql_link);
$this->rootDir = $_SERVER['DOCUMENT_ROOT']."admin/";
$this->templateDir = $this->rootDir."templates/";
$this->isAdmin();
}问题是,当我试图在我的本地开发平台(Mac OSX Lion/PHP/Mysql)上运行它时,我总是得到以下错误:
Warning: include(/Library/WebServer/Documentsadmin/templates/index/In The News/item.php) [function.include]: failed to open stream: No such file or directory in /Users/mycomputername/Sites/thewebsite.com/admin/editable.class.php on line 283我对PHP比较陌生,我假设我的php.ini文件有问题,指向了错误的web根目录,但我不确定如何解决这个问题,或者这是否就是我遇到的问题。
不过,数据库连接运行正常。
对诊断此问题的任何帮助都是非常感谢的。
发布于 2011-12-22 08:11:10
为什么不将rootDir设置为
$this->rootDir = dirname(__FILE__)."/admin";而不是?(如果需要更高的级别,可以在它周围添加更多的dirname())。
当然,假设您需要的rootDir以某种方式与此文件相关。
https://stackoverflow.com/questions/8597962
复制相似问题