ColdFusion Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreColdFusion Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old September 16th, 2005, 09:06 AM
wonderlandh wonderlandh is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Location: Nottingham UK
Posts: 60 wonderlandh User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 h 48 m 31 sec
Reputation Power: 4
using a variable as the path in a <img> tag?

Hi,

Got a path in my database for translated button graphics.

Want to stick the variable that points to the path into an <img> tag but it's not working.

Here is what i'm using:

Code:
<img src="#lang.trans[200]#" hspace="10" border="0">


My path in SQL reads: butns/eng_back.gif

and when i right click on the missing image icon that appears intead of my chosen button image, the path doesn't read "such and such.gif" but "#lang.trans[200]#".

Ideas??

Reply With Quote
  #2  
Old September 16th, 2005, 10:10 AM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,692 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 16 h 43 m 41 sec
Reputation Power: 53
Wrap it in <cfoutput>.
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian.
How to Post a Question in the Forums

Reply With Quote
  #3  
Old September 16th, 2005, 11:11 AM
wonderlandh wonderlandh is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Location: Nottingham UK
Posts: 60 wonderlandh User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 h 48 m 31 sec
Reputation Power: 4
nah, that's not it. I tried to basically output the string to error check and i got this:

The element at position 201 in dimension 1 of object "lang.trans" cannot be found. The object has elements in positions 1 through 199. Please, modify the index expression.


The error occurred while processing an element with a general identifier of (#lang.trans[201]#), occupying document position (237:5) to (237:21).

I'm outputting from a table where the rows are starting to exceed 200.

Surely this must be straightforward? The variable lang.trans is taken from a query generated by application.cfm if that means anything?

thanks

Reply With Quote
  #4  
Old September 16th, 2005, 12:13 PM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,692 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 16 h 43 m 41 sec
Reputation Power: 53
What is lang.trans? Is it an array? Use cfdump to display the variable and confirm that it has the number of elements you think it does. My guess is that array only has 200 elements in it, so when you get to 201 it throws an error. The other question to ask yourself is, is an array the appropriate type of variable to hold the data in question?

Reply With Quote
  #5  
Old September 16th, 2005, 12:47 PM
wonderlandh wonderlandh is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Location: Nottingham UK
Posts: 60 wonderlandh User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 h 48 m 31 sec
Reputation Power: 4
not overly familiar with arrays so i don't think it is.

basically there is a query called 'lang'
which selects a row like so:

"Select Italian as trans"

ergo lang.trans[] (with the row number you want to output in the brackets).

Depending on what language id you have in the database, there are several queries in application.cfm, one of which will be used.

The one above used Italian as an example, but there are a few others.

I didn't realise that it had a limit of 200 rows though?? that's not an array though is it?

So, what does "modify the index expression" mean?

please help, i've created an entire system around this and it could all fall apart horribly

Reply With Quote
  #6  
Old September 16th, 2005, 01:09 PM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,692 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 16 h 43 m 41 sec
Reputation Power: 53
I think you've jumped ahead of yourself in a couple of places. First, if the variable is a query, is there any reason why you aren't using the normal query syntax ie "myquery.mycolumn"? Why are you using the array syntax to reference the query elements?

Can't you just do (assumign the query is called lang):

<cfoutput query="lang">
<img src="#lang.trans#" hspace="10" border="0">
</cfoutput>

?

And second, when you cfdump the query, how many elements are in it? How are you deciding what row value you are using for each of the elements? Are you looping?

No there is no limit on the size or an array or query (aside from the RAM on your server). It's blowing up because you're referencing it incorrectly.

Reply With Quote
  #7  
Old September 16th, 2005, 01:38 PM
wonderlandh wonderlandh is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Location: Nottingham UK
Posts: 60 wonderlandh User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 h 48 m 31 sec
Reputation Power: 4
right,tried cfdump and got this:

Code:
ColdFusion cannot determine how to process the tag <CFDUMP>. The tag name may be misspelled.


Running 4.5 so maybe that's it.

That output you gave wouldn't work, i'll explain in full how the system works as clearly and as simply as i can.

1. Users select a language from a menu before logging on, but as they do it gets added as a number to a database. So the DB remembers their choice.

2. This gets sent to application.cfm as a session variable (session.lang)

There you'll see something like this:

Code:
<cfif isdefined("session.lang") and #session.lang# EQ 1>
<cfquery name="lang" datasource="db">
SELECT English as trans
FROM trans_admin
</cfquery>

<cfelseif isdefined("session.lang") and #session.lang# EQ 4>
<cfquery name="lang" datasource="db">
SELECT Italian as trans
FROM trans_admin
</cfquery>


and so on...

THE DATABASE
-----------------------
The database has several collumns, one for each language. The first collumn is an auto increment. So I have about 200 entries (rows) with text in.

e.g.

transID | English | Italian |
--------------------------
112 | one | Uno

so when i want to output text, i'll just put:

<cfoutput>
#lang.trans[rownumber]#
</cfoutput>

Does that make sense?

Just can't see why it's cutting me off after 200...

Reply With Quote
  #8  
Old September 16th, 2005, 02:00 PM
wonderlandh wonderlandh is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Location: Nottingham UK
Posts: 60 wonderlandh User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 h 48 m 31 sec
Reputation Power: 4
wait wait wait

I got it!!!

I thought, because (due to the odd deletion) I was outputting row number 201 (because that's what the autoID reads) when in actuality, the ammout of rows only went up to 199.

But this aint good, because now i don't have an accurate idea of what row number i'm outputting.

Off the top of your head, is there a way I could have:

#query.collumn#

and somehow specify the auto-increment number? shortness of text is key because every bit of text on the site will be dynamic in this way and i don't want blocks of code for every tiny bit of text i need to fetch.

thanks!

Reply With Quote
  #9  
Old September 16th, 2005, 02:04 PM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,692 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 16 h 43 m 41 sec
Reputation Power: 53
That's the thing, if you use

<cfoutput query="myquery">
#myquery.column1# #myquery.column2# etc...
<br>
</cfoutput>

You don't need to know how many rows there are in the query and you don't need to reference each row by number....cfoutput loops over each row in the query automatically.

I think before you go further you might want to stop and spend some time playing with queries and different ways to reference and manipulate them. Otherwise you're going to build the system without fully understanding the implications of the decisions you are making.

Reply With Quote
  #10  
Old September 16th, 2005, 02:07 PM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,692 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 16 h 43 m 41 sec
Reputation Power: 53
Also, I should note that all of this is fully described in the documentation . Also, if you can possibly upgrade your server, you should. ColdFusion 4.5 is over seven years old and has been vastly improved upon.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > using a variable as the path in a <img> tag?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT