EscalateSEO Posted May 16, 2015 Share Posted May 16, 2015 (edited) I'm trying to connect to the database to retrieve information from a specific MySQL table. My code is in a .tpl file that's associated with the Smarty template system. Here's a copy of my code: {php} $result = mysql_query("SELECT * FROM tbldownloads"); while($row = mysql_fetch_assoc($result)) { $customdata[] = $row; } $ca->assign('customdata', $customdata); {/php} <section> <table id="downloads" class="table table-striped table-bordered" cellspacing="0" width="100%"> <thead><tr><th>Name</th><th style="text-align:center;">Developer</th><th style="text-align:center;">Version</th><th style="text-align:center;">Download</th></tr></thead> <tfoot><tr><th>Name</th><th style="text-align:center;">Developer</th><th style="text-align:center;">Version</th><th style="text-align:center;">Download</th></tr></tfoot> <tbody> {foreach from=$customdata item=customdata} <tr> <td>{$customdata.title}</td> <td style="text-align:center;">{$customdata.downloads}</td> <td style="text-align:center;">{$customdata.description}</td> <td style="text-align:center;"><a href="dl.php?type=d&id={$customdata.id}" class="btn btn-primary">DOWNLOAD</a></td> </tr> {/foreach} </tbody> </table> </section> This is the error I'm getting: Fatal error: Call to a member function assign() on a non-object in /home/lximcvez/templates_c/%%B2^B21^B2190A74%%access.tpl.php on line 62 Line 62 of the outputted PHP file contains this: $ca->assign('customdata', $customdata); I'm not really sure why I'd be getting this error or what I need to change Any help would be appreciated. Edited May 16, 2015 by EscalateSEO 0 Quote Link to comment Share on other sites More sharing options...
sentq Posted May 17, 2015 Share Posted May 17, 2015 replace this line: $ca->assign('customdata', $customdata); with: $this->_tpl_vars['customdata'] = $customdata; 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.