|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
assbach Smarty Rookie
Joined: 21 Jun 2003 Posts: 11
|
Posted: Sat Jun 21, 2003 11:56 am Post subject: get vars from config for ADODB connection |
|
|
hi there,
i quite new to smarty and i am using it in combination with ADODB.
now i have set my database connection vars in the "xy.conf" file
and want to access them in my php-file....
look please:
xy.conf
---------
# hidden section
[.Database]
dbHost = localhost
dbName = name
dbUser = user
dbPass = 123456pass
xy.php
--------
Code: |
<?php
require '/path/smarty/libs/Smarty.class.php';
$smarty = new Smarty;
$smarty->caching = false;
$smarty->compile_check = true;
$smarty->config_load('xy.conf','Database');
$dbPass = $smarty->get_config_vars('dbPass');
require '/path/adodb/adodb.inc.php';
$db=NewADOConnection('mysql');
$db->Connect("localhost", "name", $dbPass, "user");
?>
|
how is the syntax? what's wrong? is there a way to do this anyway?i also tried {#dbpass#} and so on... $smarty.dbPass
please advice ... thanks alot,
sascha |
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Wed Jun 25, 2003 5:50 am Post subject: |
|
|
hi assbach.
What version of Smarty? There is a problem with 2.5.0 if your file starts immediately with a section. Try a blank line or comment before the section to see if that helps. There is more info on this issue available HERE.
Note that the issue discussed in that topic is corrected in CVS but that the current CVS is undergoing a lot of changes and is unstable for production work. |
|
Back to top |
|
assbach Smarty Rookie
Joined: 21 Jun 2003 Posts: 11
|
Posted: Thu Jul 03, 2003 2:44 pm Post subject: |
|
|
indeed, it's 2.5.0
i'm gonna try what you said,
but which syntax/way is correct then? |
|
Back to top |
|
assbach Smarty Rookie
Joined: 21 Jun 2003 Posts: 11
|
Posted: Thu Jul 03, 2003 2:51 pm Post subject: |
|
|
it seems to work, thanks alot!!!!!
BUT only with unhidden sections?!?
as soon as i put a DOT before the section name - it does not work anymore.?!? puzzled.
even with the "hack" it doesnt work for me...
|
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|