Jellyhead
Community Beginner
Jellyhead
Community Beginner
Activity
May 16, 2022
07:24 AM
1 Upvote
BRILLIANT!! Thank you. I'll email you some beer. This works 90%. Question though: Why do I sometimes get negative numbers on my days and months though? (I'm not a coder, I'm a designer who can code a bit. this stuff makes me realise how out of my depth I am!)
... View more
May 16, 2022
02:02 AM
Hello good people - I've an 'easy;' one whipping my butt. I have two random dates, I need to display how many years, months, days have passed between the dates. I've been playing around with DateDiff and its all fine to "year" level, but days and months are killing me. I tried one of Ben Nadel's techniques, but I end up with a "12" on my month counter when it should be "0". (For the record, for testing purposes I had my two dates precisely a year apart, and got 1 year and 12 months... erm, no!) Yes, I have searched these forums (and others). Yes, I got lost as none of them are helpful, either over complicared, or too siimple "Just use datediff()". I cannot beleive somehting this simple (which I can do in Excel* in 12 seconds) has now been taking all weekend on Coldfusion. *Example of Excel code which is working 100% =DATEDIF(E6,B!, "y") & " y " & DATEDIF(E6, B1, "ym") & " m " & DATEDIF(E6,B1, "md") & " d."
... View more
Dec 02, 2018
08:18 AM
I've not had time to test it yet, but yes - this is exactly it - thanks!
... View more
Nov 30, 2018
10:30 PM
Hi everyone - this is silly, I know, but... I'm a designer who can code a bit, and I have issues with font management on my system (I have about 2,000-odd fonts). so, Cleverdix here decides to quickly write his own ColdFusion font manager, easy peasy. Import all the font families into a database, add my own delimiters (such as "oh yeah" and "Crap" and 'handwritten") so that when I look for a font, I can run a query, and find the fonts I'm looking for. Heaven! Got the database set up, works like a charm. Except, of course, it does not, because coldfusion doe snot want to render the fonts. Do a bit of digging, and I find this gem: <cfset adminObj = createObject("Component", "cfide.adminapi.administrator")> <cfset adminObj.login("password", "user")> <cfset rtService = createObject("component", "cfide.adminapi.runtime")> <cfset fonts = rtService.getFonts()> Ta-dah! absolutely brilliant - I now have a struct with all my fonts... within a struct residing in a struct residing in a struct... 4 nested structs, and now I'm as lost as a Polar Bear in Australia. Questions: How do I get the "second key" and the third key, etc, so that I can loop over them and insert them into my database? with my limited knowledge, I can get the 1st struct key, which returns me "systemfonts" and "userfonts" - as useless as a snooker table on a canie. I know what the hell that second key is, and the third one, so that I can list all the variables in a way that makes sense to me. Basic desired outcome is a database that looks sort-of like this: rowid | font family | font-face | postscript name | path When I can import the family, face and postscript into my database, I'll be happy as an ant at a picnic. thank you - thank you - I'll email you a sixpack for your effort.
... View more
Jul 27, 2012
01:43 AM
Hi all – I have a dumb question – I’m not the worlds best scripter… I’ve got a ColdFusion page, with an element in it that is either flash, or HTML5. I need a way to detect what is happening client-side and push the client to either the Flash element, or the HTML element (or a s “you’re WAY behind the times” element if neither). I’ve found, and used, modernizr, but it does things the wrong way round for me. I need to direct my clients to flash 1 st , then HTML5, then the sorry page. Modernizr only gives me HTML 5 first then Flash, and this isn’t working for me. the flash element is the preferred element. I’ve screwed around with trying to “swap out” modernizr, but my glasses aren’t thick enough. Thus, I (roughly) need something that does this: <cfif “flash”> Direct them to flash page <cfelseif “html5”> Direct them to HTML 5 page <cfelse> So, how is life in the 18 th century? </cfif> Help, please.. It does not have to be CFM, it can be a JavaScript or anything.
... View more
Jul 20, 2011
12:01 AM
I have found a solution. Its not elegant, its not pretty, but it fulfils the most important criteria: happy client. This is what I did: Have the search criteria (index numbers) as a list. Run a query looking for all images with the FIRST criteria, output result set as list. Run a loop from SECOND criteria to “n” containing a second query looking for images in the list and output values to new list. Ta-dah! So I have two queries, one to just get an initial result set, and one looped. Yes its ugly, but it works!
... View more
Jul 19, 2011
01:00 PM
Shoo guys, you really have got me thinking here… the joins do not work – but I’m not that familiar with the joins… Adam Cameron is right, I want an AND not an OR – the or I’ve got sorted. So far, Owain North’s 1 st answer makes the most sense, but I can’t get it to work - something about incorrect syntax. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'IF WHERE ImageNo = I.RowId AND IF.featureno = 3 )’ Owain – help, please… Owain is also correct that I need a Rowid, not a text search. The problem I have with the “like” query is that it picks up 5, 15 and 25 when I only want 5. This thing is going to turn my remaining hairs grey…. I do however appreciate all your help, and this just showed me I know a lot less about SQL queries than I thought I did…
... View more
Jul 15, 2011
11:19 PM
Okay – here’s one for the guys smarter than me – IE: everyone. An interesting query. (CF8, MySQL5) I’m building an internal stock library for a large firm. Easy job – and its always the easy ones that knock you, ain’t it? Basically, its very very simple, I have three tables. Table 1 is a list of images (ImageTbl) – this has a lot of data on it, but the only important thing from ImageTbl is the unique identifier, RowID. It looks something like this Rowid Photo 1 Gold.jpg 2 iron.jpg 3 train.jpg 4 foo.jpg 5 bar.jpg …Etc. for hundreds of images. Table 2 is a list of features (FeatureTbl) that can be applied to any image, its literally just a RowID and a Feature, IE Rowid Feature 1 Mining 2 Coal 3 Rail Transport 4 Iron Ore 5 Road Transport 6 Refined Product 7 Gold Ore etc. for about 50-odd features. Every image that is uploaded to the system is then given AT LEAST one of these categories, but it can be as many as 9 or 10. This is where the fun starts…. So, maybe I’ve been given the wrong advice, but I’ve been told not to store strings, but to “normalise” the database, which means I’ve got a third table which has an image number and a feature number: (ImageFeaturesTbl) ImageNo FeatureNo 1 1 1 3 1 5 2 1 2 7 3 5 etc 100's of records (This is how I was told to do this, I can probably change the system if I really need to) Now they want to have a “search” function. Gimme all images that feature “coal”. Got the features list as a checklist on a form, check the feature you want, hit submit – voila! Easy – run a query on ImageFeaturesTbl and Bob is your auntie. Select imageNo from ImageFeaturesTbl where feature=#FORM.FeatureNo# Works a treat! Sits out all the images that has the "Coal" featreNo. But now, what if there are more than 2 categories? What if they want all images that has “Coal” or “gold” on it – that one I also figured out, the “OR” query. I can do a loop and search for images on ImageFeaturesTbl that has either one or the other. So this is not the problem either. The fun really starts with the “and” query – select images that has both “coal” and “rail transport”… and this is where I get stuck. I’ve literally worked till 4:00 AM this morning – and it’s a weekend; and up again at 7 trying to solve this puzzle. I’m miserable! Basically I’m wanting to get from ImageFeaturesTbl a list of image numbers that contains ALL the selected features. It could be one feature (always at least one) but it could be Nine or 10. But it has to have ALL the featurees. So the system has to give me all the images that shows coal being transported on rail in summer at the harbour, for instance. The database and tables exist, but how the hell do I write that select query…. Thanks - I'll email the winning answer a crate of beer.
... View more
Sep 29, 2010
03:21 AM
Help – been up all night and brain is flat… I have a text list, which I need to compare with n-amount of other lists. IE: Original list: “beer, whisky, wine, vodka, tequila” Then I have: List 2: “beer, chocolate, nuts” List 3: “whisky, bacon, beer” List 4: “chocolate, bacon” Etc… I need a script that compares my original list with list 2, 3 & n, and return the list number that matches ANY of the list elements. IE my result set would be “2, 3”. (the ID of the lists returned as a valuelist) Bonus point if you can arrange them by the amount of matches – “3, 2” – but non-essential. Point me in the right direction please!
... View more
Apr 20, 2010
03:11 AM
Long story short: I have a database table with literally millions of records. Every week a new column is added to this table dynamically. I need to find out the name of this column is. I tried using the getColumnList() function, and it works fine – in theory. The thing is, I have to use a “select * from” query, which I so do not want to do – I have no desire to select asterisk a couple of million records just to get a single column header value. I know I’m being an idiot here, but can someone please tell me how to get a column header from a table. CF8, MySql Thanks!
... View more
Apr 08, 2010
03:06 AM
I have an exceptionally large query that I run once a week, and it has now become very cumbersome. at any given time its 20 000 records or more. I want to output to page as the query runs - trying cfflush but it does not seem to work. Anyone have any suggestions - running CF 8.
... View more
Oct 15, 2009
10:36 PM
Adam - you are obviosuly a very wise man - not only did you solve my problem, you have enough common sense not to drink Caste. I would not force SA beer on my worst enemy's dog. Your Windhoeks are waiting for you.
... View more
Oct 15, 2009
01:26 PM
Okay. A case of beer up for grabs for the first person to get this one (you have to come to Johannesburg to get it though!) I have to write an application that extracts EXIF data from photographs uploaded to the server and stores it in a database. So I try the following: <cfimage action="read" source="#file.serverfile#" name="image" /> <cfset exif = ImageGetEXIFMetaData(image)> <cfdump var="#exif#"> <cfquery name="yadda" datasource="#dsn"> insert into pics (focal_length) values (#focallength#) where yadda yadda fishpaste. </cfquery> Problem solved, right? Wrong! The dump file gives me a bunch of variables like "Exposure Time" and "Max Aperture Value". (note the spaces). I need to isolate that "exposure time" and "Max Aperture Value" variables. <cfset focallength = ImageGetExifTag(image,"Focal Length") /> <cfoutput>#focallength#</cfoutput> Whoo hoo! But now, what if some malicious idiot uploads a file WITHOUT exif data? OOPS! This is where I get stuck - how do I test for the variable? How do I test if that variable exists? Easy enough to do without spaces. How do I do it WITH that space between "focal" and "length"? I've "isdefined" my way from hell to breakfast, without any luck! PS: its late, I'm tired, and had three beers already! Spank you in advance. Now go out and conquer!
... View more
Oct 04, 2009
11:42 PM
<cfset dir = listLast(getDirectoryFromPath(getCurrentTemplatePath()),"/") /> - does not work, gives me the same ol' same ol' <cfset dir = listGetAt(getCurrentTemplatePath(),listLen(getCurrentTemplatePath(),"/")-1,"/") /> Works a treat! This is what I was looking for - thank you, you are now the proud owner of a few beers next time you are in my hometown. G
... View more
Oct 04, 2009
05:33 AM
I need an idiot-proof way of determining the current path of the template I’m working with. If I have a path C:\ColdFusion8\wwwroot\mysite\folder\index.cfm: How do I isolate the thing that it only gives me “folder” and NOTHING else? I tried getDirectoryFromPath, but I get an “all-or nothing- type result. Please, someone put it up in idiot-code what do I need to do to just get the value of the current folder I’m in and nothing else. Please don’t tell me use “x” function – I’ve tried a few but I’m at wit’s end!
... View more
Nov 26, 2008
09:38 PM
I’m looking for a solution. I’ve got a client who
tasked me to code a newsletter system. I created a system whereby
they can add pictures and text to articles, which are then
consolidated in a single newsletter, run through a CFMAIL tag
looped through a database, and Bob’s your auntie.
Now they say, fine, but how do they do custom layouts –
“like in the included word doc”. Basically non-IT-savvy
clients wants to have their word doc mailed to their database, but
not as an attachment. (Attachment would be easy!). It needs to
display in their recipients inbox the way it looks in word –
with the normal limitations, of course. Basically – compose a
message in outlook/word and send it to the database – which
is maintained on the CF server.
I’m stumped! I thought of saving the word docs as MHT
files and embedding them in the body of the CFMAIL tag, but on the
recipient side it just laughs at me (should have guessed, was too
simple).
How can I solve this problem? Any help would be appreciated
as I’ve already spent 3 non-billable days looking for a way
to make this happen.
... View more
May 18, 2008
02:11 AM
Sweet, works a treat!
I did the following:
<cfquery name="getmax" datasource="#dsn#">
select max(rowid) as maxx from table
</cfquery>
<cfset startlimit=#getmax.maxx#-3>
<cfquery name="getrecent" datasource="#dsn#">
select rowid from table LIMIT #startlimit#, 3
</cfquery>
I've just learned something! Thank you
... View more
May 17, 2008
11:39 PM
Yes – I’m working on a Sunday.
Okay, here’s the deal: I want to retrieve the last n
(call it 5) records (non-sequential) from a table. I can easily do
this by getting my query to sort desc, and then using maxrows so
that it gives me the last 5 – but:
1) I want the last 5 to be in order – for example, I
don’t want 10, 9, 8, 7, 6, - which is what the example above
gives me, I want 6, 7, 8, 9, 10.
2) The table will have thousands, if not 10s of thousands of
records, to select just the row_id desc, will be a huge task.
Don’t want the server to work that hard – it’s
got other things to do.
My idea is as follows – using the select max(row_id) is
easy, it gives me the last record – can't I just do something
that will step back n number times from my max query and give me
the last n records?
PS: MX8, MySql 5
... View more
May 13, 2008
07:58 AM
Great - thanks - so easy. there you have it folks.
But remember to then swap the "to and "From" values as well.
<cfloop index="q" from="5" to="-5" step = "-1">
... View more
May 13, 2008
07:42 AM
So I've got a dumb q again...
<cfloop index="q" from="-5" to="5">
works perfectly and gives me numbers from -5 to 5. Counts up.
How can I make it loop / output the other way, from 5 to -5.
Counts down?
This must be so easy, yet it escapes me. Its been a long day
- forgive me.
... View more
Oct 18, 2007
12:43 AM
Thanks paross!
Sometimes I get confronted with something I'm clueless about,
esp when you are on an inherited site and you have to try to figure
out someone else's code.
did a search for "clientstorage", found it in some obscure
place, and voila, set it to cookie and we're ready to rumble!
*bows*
... View more
Oct 16, 2007
11:25 PM
Okay, a newby question, I'm sure, but here’s one.
I inherited a website, and now need to start updating and
maintaining.
Managed to connect to the DB host and set up the ColdFusion
DSN 100% fine - DSN verifies 100%.
when I try to access the site on my development server I get
"The data source named "MyDsn" is not a valid client storage DSN."
Working on CF7, MySQL 5.0
With this combination I've done many sites, just this
inherited one I'm battling with.
HELP!!
... View more
Sep 06, 2007
05:46 AM
Thanks!
that something so simple can muck you up so badly!
I've done some awesome things in CF over the past few years,
and I was frustrated beyond belief that this tiny thing could throw
me.
A simple bloody space! Ask me how much do I feel like an
idiot now.
Next time you are in my area, I'll put a beer in front of
your space.
... View more
Sep 06, 2007
02:29 AM
I’m looking for a solution. I have a bunch of random
variables, which I then need to compare with a set list, which
ranges from 1 to 97.
The variables will be in a list like “33, 45,
62”.
What I need to figure out how to do is to compare the random
variables with my set list. I used some list and find functions,
but it either gives me only the first value of 33 only, or it gives
me, 2, 3, 4, 5,6, 33, 45 and 62. I need to give it to me to give
whole numbers only. Both sets of numbers will be in ascending
numerical format.
I currently have:
<cfset qlist = ValueList(myqry.varno)>
<table>
<cfloop index="r" from="1" to="97">
<cfoutput>
<tr><td>#r# - #ListFindNoCase(qlist,
r)#</td><tr>
</cfoutput>
</cfloop>
</table>
Which gives me my list from 1 to 97 no problems, coldfusion
101 stuff, but it only gives me a true on 33, not on 45 and 62.
What can I do where to give me something like:
…
32 - 0
33 - 1
34 – 0
…
44 – 0
45 – 1
46 – 0
… etc?
I'm open to suggestions and solutions, don't take my code
example as the only way it has to be.
Thanks!
... View more
Jun 08, 2006
05:00 AM
Thanks, but I need it the other way round.
I'm searching for "2" in a set of "1,2,4,6,12,24", not to see
if my recorset contains anyone of "1,2,4,6,12,24"... if you get my
drift. the IN function's reverse is what i'm looking for.
The datatype is just text, as each record contains a list of
up to 100 integers, each separated by a comma. So I need to run
through my table, and pick up every record where the record
contains "2".
Your example only returns true if "2" is the only number in
my record.
... View more
Jun 08, 2006
02:38 AM
Easy one for the experienced guys:
I have a record with a list of comma separated values, IE,
1,2,4,6,12,24
or simply
24
I need to write a query where I find all records where the
specific number/value I'm looking for is in the list. For example
I’m looking for all records that contains the number "2".
I've used the like operator
select * from my_table where my_column like
'%#form.my_search#%'
(and a few variants), but the problem is, it finds the record
with just "24" in it as well, whereas I want records that contains
"2". And not anything that has a 2 in front or behind it.
All numbers are integers, as they refer to a row identifier
on another table.
How to do this?
Thanks
... View more