Re: PHP & smarty - nested queries and arrays

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Warning: Smarty error: unable to read resource: "welcome/Object.tpl" in
/usr/local/lib/php/Smarty/Smarty.class.php on line 1088

You should check your Smarty`s template_dir. Put the templates into the 
template_dir, then the Smarty will find them.

Like this:

$smarty = new Smarty();
$smarty->template_dir = '/home/mike/tpl/';
$smarty->display('test.tpl');

You should put the file 'test.tpl' into dir '/home/mike/tpl'.

"Amanda Hemmerich" <ahemmeri@xxxxxxxxxxx> 
??????:42FB9A2A.8000202@xxxxxxxxxxxxxx
> Hello!
>
> I'm using PHP and Smarty to try to build an array of arrays using the 
> results from nested queries.  I am just learning about nested arrays, and 
> I'm not sure what I'm doing wrong.
>
> I am hoping someone can give me a hint as to what I am doing wrong.  I 
> looked on php.net, but still couldn't figure it out.
>
> If I remove the PHP foreach loop, it works fine, except, of course, no sub 
> projects show up.   The error must be in there, but I'm just not seeing 
> it.
>
> I get the following error with the code below:
>     Warning: Smarty error: unable to read resource: "welcome/Object.tpl" 
> in /usr/local/lib/php/Smarty/Smarty.class.php on line 1088
>   PHP STUFF
> $query ="SELECT * FROM projects WHERE parent_project_id is NULL OR 
> parent_project_id = ''";
>
> $projects = $db->getAssoc($query, DB_FETCHMODE_ASSOC);
>
> foreach ($projects as $key => $project) {
>  $query ="SELECT * FROM projects WHERE parent_project_id = 
> $projects[$key]['project_id']";
>  $sub = $db->getAssoc($query, DB_FETCHMODE_ASSOC);
>  $projects[$key]['subs'] = $sub;
> }
> $tpl->assign('projects', $projects);
>   SMARTY STUFF
> {foreach from=$projects item='entry'}
>    <b>{$entry.short_name}</b><br />
>    <ul>
>    {foreach from=$entry.subs item='sub'}
>        <li>{$sub.short_name}</li>
>    {foreachelse}
>        <li>No subs for this project</li>
>    {/foreach}
>    </ul>
> {foreachelse}
>    <b>No projects found</b>
> {/foreach}
>
> Can anyone point me in the right direction?
>
> Thanks,
> Amanda 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux