php - get file path in joomla from any other directory -
i working on joomla modules facing problems. create more 7 modules , every 1 had on dbcon.php file contain connection db code. problem let suppose change password have change password in every dbcon.php file in every module not correct way. want place general dbcon.php file every module , include file in every module when ever need change credentials have chage dbcon.php file once each , every custom module.
so purpose put dbcon.php file inside modules folder , try file that
include( juri::base().'modules/dbcon.php');
which return me path
http://localhost/jmd_tests/modules/dbcon.php
which correct gives me warnings , module not working.
here warning messages
warning: include() [<a href='function.include'>function.include</a>]: http:// wrapper disabled in server configuration allow_url_include=0 in c:\wamp\www\jmd_tests\modules\mod_stune_cat_indians\helper.php on line 74 warning: include(http://localhost/jmd_tests/modules/dbcon.php) [<a href='function.include'>function.include</a>]: failed open stream: no suitable wrapper found in c:\wamp\www\jmd_tests\modules\mod_stune_cat_indians\helper.php on line 74 warning: include() [<a href='function.include'>function.include</a>]: failed opening 'http://localhost/jmd_tests/modules/dbcon.php' inclusion (include_path='.;c:\php\pear') in c:\wamp\www\jmd_tests\modules\mod_stune_cat_indians\helper.php on line 74
so stuck on here , dont know correct results. appreciate kind of help.
first of why need db file in module ?
use joomla default db object instead of file include.
like below.
$db = jfactory::getdbo(); $db->setquery('your mysql query'); $db->query(); $res = $db->loadassoclist();//for multiple rows single row use $db->loadassoc(); echo "<pre/>"; print_r($res);
this should function in module helper.
for getting correct path use. juri::root()
return http://yourdomain.com/
jpath_site
return upto /public_html in case required.
hope solve problem.
Comments
Post a Comment