【发布时间】:2014-01-05 15:47:28
【问题描述】:
我有一个 joomla 网站,我正在创建一个带有 .php 的照片库,使用 query1 SELECT 调用图片(这个 php 用完了 joomla 但从 joomla DB 调用图片)
当 gallery.php 位于我网站的根目录时,它工作正常。但是当我想将它插入一个文件夹时,我得到了这个错误:
Warning: require_once(/homez.420/xxxxx/www/gallery/includes/defines.php) [function.require-once]: failed to open stream: No such file or directory in /homez.420/xxxxx/www/gallery/gallery.php on line 30
Fatal error: require_once() [function.require]: Failed opening required '/homez.420/xxxxx/www/gallery/includes/defines.php' (include_path='.:/usr/local/lib/php') in /homez.420/xxxxx/www/gallery/gallery.php on line 30
我还是 php 的新手,我无法找到如何让这两行从图库文件夹中跳出,以便它调用此文档:/homez.420/xxxxx/www /includes/defines.php
require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );
这是完整的代码
<?php
define( '_JEXEC', 1 );
define('JPATH_BASE', dirname(__FILE__) ); //this is line 30 : where the glitch is
define( 'DS', DIRECTORY_SEPARATOR );
require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );
$mainframe =& JFactory::getApplication('site');
$mainframe->initialise();
$db = &JFactory::getDBO();
?>
非常感谢您的帮助!
【问题讨论】:
-
你需要把这一行改成它指向正确的目录:
define('JPATH_BASE', dirname(__FILE__) );....另外,你不需要使用$db1和$db2,只要定义它曾经这样:$db = JFactory::getDbo(); -
感谢洛德的回复!我为 $db1 和 $db2 感到抱歉,我确实将其更改为 $db = JFactory::getDbo();。我确实理解您所说的“您需要将此行更改为它指向正确的目录”的意思,但我不知道该怎么做。我应该做类似的事情:
define('JPATH_BASE', dirname(/homez.420/xxxxx/www/) );?再次感谢您的帮助! -
您的图库脚本目前位于以下文件夹
homez.420/xxxxx/www/gallery,但是您的Joomla 站点的根目录在哪里?像这样的东西>>homez.420/xxxxx/www/joomla?一旦我知道了你的 Joomla 网站的根目录,我就可以为你的代码给出一个具体的答案 -
它是 /homez.420/xxxxx/www
标签: php joomla require-once