SELECT * FROM Test SELECT * FROM qGetPictures WHERE ID = #URL.ID#
Prev image | Next image
[allowsmilie] => 1 [showsignature] => 0 [ipaddress] => [iconid] => 0 [visible] => 1 [attach] => 0 [infraction] => 0 [reportthreadid] => 0 [isusenetpost] => 1 [msgid] => [ref] => [htmlstate] => on_nl2br [postusername] => murpg [ip] => webforumsuser@m [isdeleted] => 0 [usergroupid] => [membergroupids] => [displaygroupid] => [password] => [passworddate] => [email] => [styleid] => [parentemail] => [homepage] => [icq] => [aim] => [yahoo] => [msn] => [skype] => [showvbcode] => [showbirthday] => [usertitle] => [customtitle] => [joindate] => [daysprune] => [lastvisit] => [lastactivity] => [lastpost] => [lastpostid] => [posts] => [reputation] => [reputationlevelid] => [timezoneoffset] => [pmpopup] => [avatarid] => [avatarrevision] => [profilepicrevision] => [sigpicrevision] => [options] => [akvbghsfs_optionsfield] => [birthday] => [birthday_search] => [maxposts] => [startofweek] => [referrerid] => [languageid] => [emailstamp] => [threadedmode] => [autosubscribe] => [pmtotal] => [pmunread] => [salt] => [ipoints] => [infractions] => [warnings] => [infractiongroupids] => [infractiongroupid] => [adminoptions] => [profilevisits] => [friendcount] => [friendreqcount] => [vmunreadcount] => [vmmoderatedcount] => [socgroupinvitecount] => [socgroupreqcount] => [pcunreadcount] => [pcmoderatedcount] => [gmmoderatedcount] => [assetposthash] => [fbuserid] => [fbjoindate] => [fbname] => [logintype] => [fbaccesstoken] => [newrepcount] => [vbseo_likes_in] => [vbseo_likes_out] => [vbseo_likes_unread] => [temp] => [field1] => [field2] => [field3] => [field4] => [field5] => [subfolders] => [pmfolders] => [buddylist] => [ignorelist] => [signature] => [searchprefs] => [rank] => [icontitle] => [iconpath] => [avatarpath] => [hascustomavatar] => 0 [avatardateline] => [avwidth] => [avheight] => [edit_userid] => [edit_username] => [edit_dateline] => [edit_reason] => [hashistory] => [pagetext_html] => [hasimages] => [signatureparsed] => [sighasimages] => [sigpic] => [sigpicdateline] => [sigpicwidth] => [sigpicheight] => [postcount] => 1 [islastshown] => [isfirstshown] => 1 [attachments] => [allattachments] => ) --> Problem with function ListGetAt - Coldfusion - Advanced Techniques

Problem with function ListGetAt - Coldfusion - Advanced Techniques

I have written the code for a DB driven image viewer. It is pretty simple. I am having a problem with my navagtion going to the previous and next links. The times when I have a problem is when I am on the number 2 in my list I don't see the previous link to get me to number 1. The other time when I see a problem is when I try to start on the number 1 in the list I get this error message. Error Occurred While Processing Request Invalid list index 0. In function ListGetAt(list, index [, ...

  1. #1

    Default Problem with function ListGetAt

    I have written the code for a DB driven image viewer. It is pretty simple. I
    am having a problem with my navagtion going to the previous and next links.
    The times when I have a problem is when I am on the number 2 in my list I don't
    see the previous link to get me to number 1. The other time when I see a
    problem is when I try to start on the number 1 in the list I get this error
    message.

    Error Occurred While Processing Request
    Invalid list index 0.
    In function ListGetAt(list, index [, delimiters]), the value of index, 0, is
    not a valid as the first argument (this list has 10 elements). Valid indexes
    are in the range 1 through the number of elements in the list.

    The Error Occurred in C:\CFusionMX\wwwroot\hunter\image_display.cfm: line 36

    34 : <cfset nextImageID = ListGetAt(ImageIDList, nextPos)>
    35 : <cfset prevPos = Listfind(ImageIDList, url.ID, ",") - 1>
    36 : <cfset prevImageID = ListGetAt(ImageIDList, prevPos)>
    37 :
    38 : <table width="100%" border="0" cellpadding="0" cellspacing="0"
    bgcolor="#9999CC">


    Can someone please help.



    <!--- Get All Pictures --->
    <cfquery name="qGetPictures" datasource="hmddb">
    SELECT *
    FROM Test
    </cfquery>

    <!--- Query the original query to grab 1 Picture --->
    <cfquery name="qGetSinglePic" dbtype="query">
    SELECT *
    FROM qGetPictures
    WHERE ID = #URL.ID#
    </cfquery>

    <!--- mechanism to grab Image IDS --->
    <cfset ImageIDList="">
    <!--- Make List of the Picture IDs --->
    <cfloop query="qGetPictures">
    <cfset ImageIDList=#ListAppend(ImageIDList, qGetPictures.ID)#>
    </cfloop>

    <!--- Get the Locations of the ID in the List --->
    <!--- Set the IDs for the next and prev buttons --->
    <cfset nextPos = Listfind(ImageIDList, url.ID, ",") + 1>
    <cfset nextImageID = ListGetAt(ImageIDList, nextPos)>
    <cfset prevPos = Listfind(ImageIDList, url.ID, ",") - 1>
    <cfset prevImageID = ListGetAt(ImageIDList, prevPos)>

    <table width="100%" border="0" cellpadding="0" cellspacing="0"
    bgcolor="#9999CC">
    <tr>
    <cfoutput query="qGetSinglePic">
    <td align="center"><img src=Portfolio/images/5/#imageName#></td>
    </cfoutput>
    </tr>
    <tr>
    <td align="center"><cfoutput><cfif ListFirst(ImageIDList , ",") NEQ
    prevImageID> <a href="image_display.cfm?ID=#prevImageID#">Prev image</a></cfif>
    | <cfif ListLast(ImageIDList , ",") NEQ nextImageID><a
    href="image_display.cfm?ID=#nextImageID#">Next image</a></cfif></cfoutput></td>
    </tr>

    </table>

    murpg Guest

  2. #2

    Default Re: Problem with function ListGetAt

    The following is certain to cause errors at some point:
    <cfset prevPos = Listfind(ImageIDList, url.ID, ",") - 1>
    because when the listfind() returns 1 then prevPos will be 0, and
    as you can see it causes an error when you use ListGetAt() with a zero
    position.



    OldCFer Guest

  3. #3

    Default Re: Problem with function ListGetAt

    I understand what's causing this, but how do I fix it? I can't think the logic all the way through.
    murpg Guest

  4. #4

    Default Re: Problem with function ListGetAt

    Without writing the code for you, here's how to fix it:

    You need to add <cfif> logic...
    Page 1 does not have a "previous" link and the last page does not have a
    "next" link.

    Such logic would eliminate the listindex problems you are seeing.

    -- MikeR

    MikerRoo Guest

Similar Threads

  1. ListGetAt in CFQUERY
    By Web Mountaineer in forum Coldfusion - Advanced Techniques
    Replies: 2
    Last Post: March 15th, 02:21 AM
  2. Problem using GD function
    By Sander Bosman in forum PHP Development
    Replies: 1
    Last Post: July 16th, 09:31 PM
  3. problem with db function php
    By Marc Collin in forum PHP Development
    Replies: 1
    Last Post: April 28th, 06:59 PM
  4. Problem stopping a function
    By davidverhulst in forum Macromedia Flash Actionscript
    Replies: 3
    Last Post: February 26th, 10:40 PM
  5. Function Problem
    By MyaTiX in forum ASP Database
    Replies: 4
    Last Post: December 29th, 03:06 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •