JFactory,JDatabase class not found in /var/www/joo

2019-09-09 02:10发布

I am trying to make connection to my data base but i am getting error JFactory class not found /var/www/joomla2.5/database.php my code is

$db= JFactory::getDBO();

I have also tried to make database connection externally but then iam getting the error JDatabase class not found

<?php
$option = array(); //prevent problems

$option['driver']   = 'mysql';            
$option['host']     = 'localhost';    
$option['user']     = 'xxxx';       
$option['password'] = 'xxxx';   
$option['database'] = 'xxxx';      
$option['prefix']   = 'cdri_';             

$db = & JDatabase::getInstance( $option );
?> 

I have checked my factory.php file it has a abstract JFactory class defined.

I am using joomla2.5 and Ubuntu12.04 OS

need help...

1条回答
戒情不戒烟
2楼-- · 2019-09-09 02:38

Just putting a file inside joomla folder doesn't gave it access to joomla libraries. Either make it as standard joomla component or module or add follwing code to your php file

define( '_JEXEC', 1 );
define('JPATH_BASE', dirname(__FILE__).'/' );   // should point to joomla root
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');
查看更多
登录 后发表回答