Pears DB Abstraction and Smarty
| From: | chiefmonkey | Date: | Wed, 20 Feb 2002 09:44:35 +0000 |
| Subject: | Pears DB Abstraction and Smarty | ||
| Groups: | php.smarty.general | ||
| Request: | Send a blank email to php-smarty-general+get-2762@lists.php.net to get a copy of this message | ||
Folks,
You will need to bear with me as I am just getting to know Smarty and Pear. I am trying to use Pears DB abstraction layer to fetch results from my database and display them in a templatedbcon.php <?php //Include the extraction layer include("DB.php"); //connect to the database $dbh=DB::connect("mysql://username:password@localhost/database"); //execute query $query="SELECT * FROM latestnews"; $result= $dbh->query($query); $row=$result->fetchrow(DB_FETCHMODE_ASSOC))
$dbh->disconnect();?> This is the code in the template {include_php file="dbcon.php"} {foreach item=$section from=$row}
{$section.story} {$section.name}<br>
{/foreach}
I keep getting this parse error
Parse error: parse error, expecting `']'' in c:\program files\apache group\apache\htdocs\smarty\templates_c\3e\3e689f54f3aa9a59bbd672da7957986f\d41d8cd98f00b204e9800998ecf8427e.php on line 8
TIA
George