Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.

passing row from database: following instructions, no work

 
Post new topic   Reply to topic    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
jamminjames
Smarty Rookie


Joined: 26 Dec 2018
Posts: 5

PostPosted: Fri Dec 28, 2018 7:49 am    Post subject: passing row from database: following instructions, no work Reply with quote

Smarty doc here https://www.smarty.net/docs/en/api.assign.tpl says I should be able to assign a row from a database like so:
Code:
$sql = 'select id, name, email from contacts where contact ='.$id;
$smarty->assign('contact', $db->getRow($sql));

Then, in the template, call it with
Code:
{$contact.name}
for example.

I did exactly that, but I'm getting an undefined index error.
I have:
Code:
$sql="select active,companyname from control where id=1";
$smarty->assign('id', $db->getRow($sql));

and
Code:
{$id.companyname}
in the template. What am I doing wrong?

I'm also getting this error:
Quote:
Fatal error: Uncaught Error: Call to undefined method mysqli::getRow()

...that's a PEAR function, I believe, and I do have that installed and working.

Thanks for any help!
Back to top
View user's profile Send private message
jamminjames
Smarty Rookie


Joined: 26 Dec 2018
Posts: 5

PostPosted: Fri Dec 28, 2018 8:40 am    Post subject: MDB2 package Reply with quote

Okay, didn't have PEAR MDB2 package installed, which apparently is needed to run getRow(). It is now installed, and I restarted the Xampp Apache server, but I'm still getting the error.
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1532

PostPosted: Tue Jan 01, 2019 4:29 am    Post subject: Reply with quote

I don't understand, what this has to do with Smarty.
Please make sure the data you pass to Smarty object contains what you expect.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP