Re: Pears DB Abstraction and Smarty
| From: | Jason Sweat | Date: | Wed, 20 Feb 2002 12:47:30 +0000 |
| Subject: | Re: Pears DB Abstraction and Smarty | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-2773@lists.php.net to get a copy of this message | ||
try taking a look at http://www.zend.com/zend/tut/tutsweatpart1.php
for an
example of using PEAR DB and Smarty.
----- Original Message -----
From: "chiefmonkey" <chiefmonkey@wisemonkeydesign.co.uk>
To: <smarty@lists.ispi.net>
Sent: Wednesday, February 20, 2002 3:44 AM
Subject: [smarty] Pears DB Abstraction and Smarty
>
> 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 template
>
> dbcon.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\d
41d8cd98f00b204e9800998ecf8427e.php
> on line 8
>
> TIA
> George
>
>
>
>
>
>
>
> ---
> You are currently subscribed to smarty as: sweatjejm@mchsi.com
> To unsubscribe send a blank email to $subst('Email.Unsub')
> Visit Smarty's homepage at
> http://www.phpinsider.com/php/code/Smarty/