Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Inserting data from a MySQL database into a Smarty template
Goto page Previous  1, 2
 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
TGKnIght
Smarty Junkie


Joined: 07 Sep 2005
Posts: 580
Location: Philadelphia, PA

PostPosted: Thu Apr 05, 2007 1:31 pm    Post subject: Reply with quote

Okay well if it's outputting the word Array then that means you ARE getting output... This would be the same behavior as if you echo'd an array. (Which you are) Have you tried accessing any of the elements of the array?
_________________
Smarty site with one index.php controller file
Working with MySQL and Smarty
SmartyColumnSort
Custom Smarty Javascript Debug Template
Back to top
View user's profile Send private message Visit poster's website
Royal_Smartiness_15
Smarty Rookie


Joined: 29 Dec 2006
Posts: 16

PostPosted: Thu Apr 05, 2007 5:27 pm    Post subject: Reply with quote

No lol, actually all the years (almost 3) that I've been learning PHP I haven't really used arrays that much lol, it's something I really should learn. Very Happy
Back to top
View user's profile Send private message
Royal_Smartiness_15
Smarty Rookie


Joined: 29 Dec 2006
Posts: 16

PostPosted: Fri Apr 06, 2007 10:49 pm    Post subject: Reply with quote

Hello...anyone?
Back to top
View user's profile Send private message
Nathan Malone
Smarty n00b


Joined: 07 Apr 2007
Posts: 3

PostPosted: Sat Apr 07, 2007 2:58 am    Post subject: Reply with quote

www.phpinsider. com/smarty-forum/viewtopic.php?p=35493 (take out space in URL) contains some sample code for looping through arrays that you might find helpful.
Back to top
View user's profile Send private message
Royal_Smartiness_15
Smarty Rookie


Joined: 29 Dec 2006
Posts: 16

PostPosted: Sat Apr 07, 2007 8:31 am    Post subject: Reply with quote

The address you gave me doesn't work, and yes I did take out the space.
Back to top
View user's profile Send private message
TGKnIght
Smarty Junkie


Joined: 07 Sep 2005
Posts: 580
Location: Philadelphia, PA

PostPosted: Mon Apr 09, 2007 2:21 pm    Post subject: Reply with quote

Arrays are simple, they are variables that have multiple values within them.'

From your PHP file use print_r($varname) to dump the values within the array in question.

You will see the KEYS and VALUES within the array.

In PHP you access the values of an array like so

Code:

$array['key'];


In Smarty you access them like
Code:

{$array.key}


http://smarty.php.net/manual/en/language.syntax.variables.php

You really need to learn about arrays if you want to work with datasets
_________________
Smarty site with one index.php controller file
Working with MySQL and Smarty
SmartyColumnSort
Custom Smarty Javascript Debug Template
Back to top
View user's profile Send private message Visit poster's website
Royal_Smartiness_15
Smarty Rookie


Joined: 29 Dec 2006
Posts: 16

PostPosted: Mon Apr 09, 2007 10:38 pm    Post subject: Reply with quote

OK so I tried every possible combination from that page and I also read all about arrays on PHP.net but nothing I tried worked...But I can't figure out why...Sad
Back to top
View user's profile Send private message
TGKnIght
Smarty Junkie


Joined: 07 Sep 2005
Posts: 580
Location: Philadelphia, PA

PostPosted: Tue Apr 10, 2007 1:10 pm    Post subject: Reply with quote

Do you have your smarty debug template up? It should show you all the variables assigned to smarty. From there you can figure out what keys are in the variable.

If there's no debug template appearing try putting a {debug} into the template you're debugging.

http://smarty.php.net/manual/en/language.function.debug.php
_________________
Smarty site with one index.php controller file
Working with MySQL and Smarty
SmartyColumnSort
Custom Smarty Javascript Debug Template
Back to top
View user's profile Send private message Visit poster's website
Royal_Smartiness_15
Smarty Rookie


Joined: 29 Dec 2006
Posts: 16

PostPosted: Tue Apr 10, 2007 2:08 pm    Post subject: Reply with quote

OK so I've followed the instructions from the link but I get the following error:

Code:

Warning: Smarty error: unable to read resource: "includes/debug.tpl"


I've checked and the debug.tpl file is there...
Back to top
View user's profile Send private message
Royal_Smartiness_15
Smarty Rookie


Joined: 29 Dec 2006
Posts: 16

PostPosted: Thu Apr 12, 2007 9:06 pm    Post subject: Reply with quote

I've tried lots of different ways of trying to get the debug.tpl file included into my template but none have, any help here would be appreciated.

Thanks. Smile
Back to top
View user's profile Send private message
TGKnIght
Smarty Junkie


Joined: 07 Sep 2005
Posts: 580
Location: Philadelphia, PA

PostPosted: Sat Apr 14, 2007 11:30 pm    Post subject: Reply with quote

Would need to see your smarty class, and anywhere you setup paths and smarty related things to help on this.

Try using absolute paths instead of relative ones i.e. "C:/include/" instead of "/include"
_________________
Smarty site with one index.php controller file
Working with MySQL and Smarty
SmartyColumnSort
Custom Smarty Javascript Debug Template
Back to top
View user's profile Send private message Visit poster's website
Royal_Smartiness_15
Smarty Rookie


Joined: 29 Dec 2006
Posts: 16

PostPosted: Sun Apr 15, 2007 10:59 am    Post subject: Reply with quote

Never mind lol, I figured it out.

I just put the debug.tpl into every directory till one worked Very Happy

Here is what it said:
Code:

included templates & config files (load time in seconds)
    default/index_body.tpl (0.06465) (total)
    default/header.tpl (0.02283)
    default/footer.tpl (0.03177)
assigned template variables
    {$sitename}    Array (0)
assigned config file variables (outer template scope)
    {#files#}    Array (0)
    {#vars#}    Array (0)


What does this mean?
Back to top
View user's profile Send private message
Royal_Smartiness_15
Smarty Rookie


Joined: 29 Dec 2006
Posts: 16

PostPosted: Wed Apr 18, 2007 2:38 pm    Post subject: Reply with quote

*BUMP*
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General All times are GMT
Goto page Previous  1, 2
Page 2 of 2

 
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