Can’t use query results within a tag?!?
Posted: 16 May 2008 08:34 AM   [ Ignore ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  350
Joined  11-29-2005

I’m using the following query

{exp:query sql="SELECT screen_name,occupation,interests,avatar_filename FROM exp_members WHERE group_id = '7'"}

to pull member data.

For some reason, {avatar_filename} won’t parse when it’s inside an html tag. For example, /images/{avatar_filename} outputs /images/.

If I place {avatar_filename} on it’s own, outside an html tag, it parses fine.

I tried to work around this by assigning a variable like so

{assign_variable:avatarimage="{avatar_filename}"}

but the behavior is exactly the same: {avatarimage} parses fine, but /images/{avatarimage} doesn’t.

Help!

Profile
 
 
Posted: 16 May 2008 09:48 AM   [ Ignore ]   [ # 1 ]  
Moderator
Avatar
RankRankRankRankRankRankRank
Total Posts:  15408
Joined  05-15-2004

Can you post the relavant part of you template, ie the whole query tag?

 Signature 

Everything will be good in the end. If it’s not good, it’s not the end.

Profile
MSG
 
 
Posted: 16 May 2008 10:01 AM   [ Ignore ]   [ # 2 ]  
Moderator
Avatar
RankRankRankRankRankRankRank
Total Posts:  12395
Joined  04-29-2002

When I use your code, this is my output:
(using {screen_name} - {avatar_filename}<br />)
Rebecca - uploads/avatar_1.jpg

uploads/filename.jpg is what the avatar_filename is pointing to. It doesn’t get the rest of the path.

 Signature 

Quick Reference - EE Trial Options - EE Wiki - Docs for updating a build

Profile
MSG
 
 
Posted: 16 May 2008 10:09 AM   [ Ignore ]   [ # 3 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  350
Joined  11-29-2005

Ingmar, here’s the full tag:

{exp:query sql="SELECT screen_name,occupation,interests,avatar_filename FROM exp_members WHERE group_id = '7'"}
<div class="contributer">
    
{assign_variable:avatarimage="{avatar_filename}"}
    {avatarimage}
    
<img src="/images/{avatarimage}" />
<
p>
{interests}<br />
<
strong>{screen_name}</strong><br />
<
em>{occupation}</em>
</
p>
</
div>
{/exp:query}


Sue - try wrapping {screen_name} - {avatar_filename} in an html tag (even something like <span class=”{avatar_filename}”> to test it)

Profile
 
 
Posted: 16 May 2008 10:22 AM   [ Ignore ]   [ # 4 ]  
Moderator
Avatar
RankRankRankRankRankRankRank
Total Posts:  12395
Joined  04-29-2002

Works for me..

Test

{exp:query sql="SELECT screen_name,occupation,interests,avatar_filename FROM exp_members WHERE group_id = '1'"}
{screen_name}
- <img src="/images/avatars/{avatar_filename}" /><br />
{/exp:query}

I had to add /images/avatars/ to the {avatar_filename) value to achieve a valid filename.

 Signature 

Quick Reference - EE Trial Options - EE Wiki - Docs for updating a build

Profile
MSG
 
 
Posted: 16 May 2008 10:32 AM   [ Ignore ]   [ # 5 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  350
Joined  11-29-2005

Sue, I tried this on a blank template, and it works for me too. Something very strange is going on. I’m going to just delete this template file and start with a fresh one. Weird weird weird…

Profile
 
 
Posted: 16 May 2008 10:36 AM   [ Ignore ]   [ # 6 ]  
Moderator
Avatar
RankRankRankRankRankRankRank
Total Posts:  12395
Joined  04-29-2002

Yup, yup, yup.. clean templates are often best. smile

 Signature 

Quick Reference - EE Trial Options - EE Wiki - Docs for updating a build

Profile
MSG
 
 
Posted: 16 May 2008 10:41 AM   [ Ignore ]   [ # 7 ]  
Moderator
Avatar
RankRankRankRankRankRankRank
Total Posts:  15408
Joined  05-15-2004

Hehe, the “clean slate” school of development smile I’m a disciple, too. Closing this thread for now, just open a new one if anything else comes up, thank you.

 Signature 

Everything will be good in the end. If it’s not good, it’s not the end.

Profile
MSG
 
 
   
 
 
‹‹ MSM + Forum      SQL query not working ››
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 1149, on July 16, 2007 09:33 AM
Total Registered Members: 64978 Total Logged-in Users: 29
Total Topics: 82017 Total Anonymous Users: 22
Total Replies: 440823 Total Guests: 192
Total Posts: 522840    
Members ( View Memberlist )