Question

String index out of range: 0

Asked by: LozLaura17

Hi i have been running a test on the last page of my project and i cannot seem to get over the error that comes up.  can someone explain where i am going wrong.  the error is :

String index out of range: 0
 
The error occurred in C:\CFusionMX\wwwroot\Project\Beginner\RAM.cfm: line 176

174 : #CurrentRAMSize.TotalRAM#
175 :
176 : <cfif isDefined(#CurrentRAMSize.TotalRAM#)>
177 :       <cfif #CurrentRAMSize.TotalRAM# GTE #MINALLOWABLE#>
178 :             <a href="GraphicsCard.cfm?level=#url.level#&type=#url.type#&name=#url.name#"> Move To Next Component</a>

The code that it applys to is:

<cfoutput>      

<cfquery name="CurrentRAMSize" datasource="database">
SELECT SUM (TBLRAM.RAMSIZE) AS TotalRAM
FROM TBLRAM
WHERE TBLRAM.RAMID in (SELECT TBLSELECTEDCOMPONENTS.COMPONENTID
                  FROM TBLSELECTEDCOMPONENTS
                  WHERE TBLSELECTEDCOMPONENTS.USERID = #session.name#)
</cfquery>
                        
<cfif #session.type# eq 'Business'>
      <cfset MINALLOWABLE = 256>
<cfelseif #session.type# eq 'Gaming'>
      <cfset MINALLOWABLE = 512>
<cfelseif #session.type# eq 'Home'>
      <cfset MINALLOWABLE = 256>
<cfelse>
    <cfset MINALLOWABLE = 0>
</cfif>

#CurrentRAMSize.TotalRAM#

<cfif isDefined(#CurrentRAMSize.TotalRAM#)>
      <cfif #CurrentRAMSize.TotalRAM# GTE #MINALLOWABLE#>
            <a href="GraphicsCard.cfm?level=#url.level#&type=#url.type#&name=#url.name#"> Move To Next Component</a>
      <cfelse>
            More Ram Required
      </cfif>
<cfelse>
      More Ram Required
</cfif>
</cfoutput>
                        

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2006-03-09 at 12:07:14ID21767654
Tags

index

,

out

,

string

,

0

,

range

Topic

ColdFusion Application Server

Participating Experts
2
Points
400
Comments
16

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. Cfquery within a Cfoutput
    I have a problem creating a menu page. What happens is the user selects a reports and from a table the report is generated. Each field that makes the report can contain a list, and the list has to be generated from SQL. The first part works fine, getting the lists and assig...
  2. <CFScript> Vs <CFSet> and <CFIF>
    Is <CFScript> faster than <CFSet> and <CFIF> Example <CFScript> if(1=1){ foo=true; } </CFScript> vs <cfif 1 is 1> <cfset foo=true/> </cfif> Which one is better proformace wise???????
  3. Problem with CFLOOP and CFOUTPUT
    In the following code, I am retrieving the Date of Birth pre-filled for each person that is related to one another. The like field is the Emp_SSN field. That reflects the Social Sec. No. of the parent. 3 people get retrieved. PROBLEM 1: In the Month select, there are 3 ...
  4. if null cfset
    Simple question.... I have some nulls returning from a query and I'd like to set the values equal to something. I've tried it a few different ways. <cfif #something# eq NULL> <cfset something = "NA"> </cfif> ...with this I get an error <...
  5. problems with cfoutput and cfif statements
    I have hardcoded (bad-i know) a table for a May events calendar. Users can search for events by choosing one option at a time. If the search phrase matches I want to change the color of the cell and output the day number for the event date on the calendar. If the search ph...

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: mkishlinePosted on 2006-03-09 at 12:18:54ID: 16148314

Try <cfif isDefined('CurrentRAMSize.TotalRAM')>

 

by: LozLaura17Posted on 2006-03-09 at 12:41:48ID: 16148598

Element COMPONENTID is undefined in ALREADYSELECTED.
 
The error occurred in C:\CFusionMX\wwwroot\Project\Beginner\Queries\Queriesc.cfm: line 17

15 : AND TBLSELECTEDCOMPONENTS.COMPONENTID = #ANSWER1#
16 :
17 : <cfif isDefined(#AlreadySelected.COMPONENTID#)>
18 :       UPDATE TBLSELECTEDCOMPONENTS
19 :       SET TBLSELECTED.NUMBERSELECTED = ((#AlreadySelected.NUMBERSELECTED#) + 1)

 

by: LozLaura17Posted on 2006-03-09 at 12:45:03ID: 16148641

The error appear and i cannot see why

<!--- Session Variables --->
<cfset session.level = url.level>
<cfset session.type = url.type>
<cfset session.name = url.name>

<cfoutput>
<cfset session.answer1= #Form.ANSWER1#>
</cfoutput>

<cfoutput>
<cfquery name="AlreadySelected" datasource="database">
SELECT TBLSELECTEDCOMPONENTS.COMPONENTID, TBLSELECTEDCOMPONENTS.NUMBERSELECTED
FROM TBLSELECTEDCOMPONENTS
WHERE TBLSELECTEDCOMPONENTS.USERID = #session.name#
AND TBLSELECTEDCOMPONENTS.COMPONENTID = #ANSWER1#

<cfif isDefined(#AlreadySelected.COMPONENTID#)>
      UPDATE TBLSELECTEDCOMPONENTS
      SET TBLSELECTED.NUMBERSELECTED = ((#AlreadySelected.NUMBERSELECTED#) + 1)
      WHERE TBLSELECTEDCOMPONENTS.USERID = #session.name#
      AND TBLSELECTEDCOMPONENTS.COMPONENTID = #ANSWER1#      
<cfelse>
      INSERT INTO TBLSELECTEDCOMPONENTS(USERID, COMPONENTID, NUMBERSELECTED)
      VALUES (#session.name#, #ANSWER1#,1)
</cfif>
 
</cfquery>

</cfoutput>

<cfoutput> <cflocation url="../RAM.cfm?level=#url.level#&type=#url.type#&name=#url.name#"></cfoutput>

 

by: mkishlinePosted on 2006-03-09 at 12:56:28ID: 16148798

The reason that componentID is not defined in AlreadySelected is that you are currently in the middle of running the query that will be assigned to "AlreadySelected" and it hasn't actually been constructed yet. Any time that you're doing an isDefined() check, don't use pound signs, just encompass the string with quotation marks (ie isDefined('AlreadySelected.ComponentID') )

 

by: trailblazzyr55Posted on 2006-03-09 at 13:05:20ID: 16148931

give this a try...


<cfoutput>    

<cfquery name="CurrentRAMSize" datasource="database">
SELECT SUM(TBLRAM.RAMSIZE) AS TotalRAM
FROM TBLRAM
WHERE TBLRAM.RAMID in (SELECT TBLSELECTEDCOMPONENTS.COMPONENTID
               FROM TBLSELECTEDCOMPONENTS
               WHERE TBLSELECTEDCOMPONENTS.USERID = #session.name#)
</cfquery>

<cfswitch expression="#session.type#">
      <cfcase value="Business">
            <cfset MINALLOWABLE = 256>
      </cfcase>
      <cfcase value="Gaming">
            <cfset MINALLOWABLE = 512>
      </cfcase>
      <cfcase value="Home">
            <cfset MINALLOWABLE = 256>
      </cfcase>
      <cfdefaultcase>
            <cfset MINALLOWABLE = 0>
      </cfdefaultcase>
</cfswitch>

#CurrentRAMSize.TotalRAM#

<cfif isDefined("CurrentRAMSize.TotalRAM")>
     <cfif CurrentRAMSize.TotalRAM GTE MINALLOWABLE>
          <a href="GraphicsCard.cfm?level=#url.level#&type=#url.type#&name=#url.name#"> Move To Next Component</a>
     <cfelse>
          More Ram Required
     </cfif>
<cfelse>
     More Ram Required
</cfif>
</cfoutput>

 

by: LozLaura17Posted on 2006-03-09 at 14:13:56ID: 16149720

I now have two problems on this means that it keeps going in an endless loop and never getting to move to next component

and when i add the field into test it moves forward a page before outputting

Parameter 1 of function IsDefined, which is now &quot;PCI-E&quot;, must be a syntactically valid variable name.
 
The error occurred in C:\CFusionMX\wwwroot\Project\Beginner\Queries\Queries7.cfm: line 31

29 : <cfset FREEPCI = #MboardPCI.PCI# >
30 :
31 : <cfif isDefined (#GcardInterface.INTERFACETYPE#)>
32 :       <cfif #GcardInterface.INTERFACETYPE# eq 'PCI'>
33 :             <cfset FREEPCI = ((#FREEPCI#) - 1)>

 

by: trailblazzyr55Posted on 2006-03-09 at 14:34:48ID: 16149966

i see with your script here you have #'s used incorrectly

29 : <cfset FREEPCI = #MboardPCI.PCI# >
30 :
31 : <cfif isDefined (#GcardInterface.INTERFACETYPE#)>
32 :      <cfif #GcardInterface.INTERFACETYPE# eq 'PCI'>
33 :           <cfset FREEPCI = ((#FREEPCI#) - 1)>


isdefined() like mkishline mentioned above should not have #'s in it. With the little code I see above in the error output... change those to be...

29 : <cfset FREEPCI = MboardPCI.PCI >
30 :
31 : <cfif isDefined ("GcardInterface.INTERFACETYPE")>
32 :      <cfif GcardInterface.INTERFACETYPE eq 'PCI'>
33 :           <cfset FREEPCI = FREEPCI - 1>

you actually don't need #'s in any of that...

 

by: trailblazzyr55Posted on 2006-03-09 at 14:35:47ID: 16149975

the only time you really need to use #'s is when you're outputing something, otherwise they are not needed...

 

by: LozLaura17Posted on 2006-03-09 at 14:53:23ID: 16150161

Hi I seem to have 3 problems left when i place in this bit of code all the possibilities disappear, as talked about 6 comments above i also seem to be stuck in an endless loop at one page

<cfif FREEPCI eq 0>
AND NOT (TBLNETWORKCARD.TYPE = 'PCI')
<cfelse>
AND TBLNETWORKCARD.TYPE = 'PCI'
</cfif>

<cfif MANUFACTURER eq 'Not Selected'>
<cfelse>
AND (TBLCOMPONENT.MANUFACTURER = #MANUFACTURER#)
</cfif>

<cfif NETWORKCARDTYPE eq 'Not Selected'>
<cfelse>
AND (TBLCOMPONENT.TYPE = TYPE)
</cfif>

<cfif DATATRANSFERRATE eq 'Not Selected'>
<cfelse>
AND (TBLCOMPONENT.DATATRANSFERRATE >=# DATATRANSFERRATE#)
</cfif>

and finally if for some reason i click submit and do not choose one of the possibilities it has a hissy fit on most of the pages
 Element ANSWER1 is undefined in FORM.
 
The error occurred in C:\CFusionMX\wwwroot\Project\Beginner\Queries\Queriesa.cfm: line 7

5 : <cfoutput>
6 :
7 : <cfset session.answer1= #Form.ANSWER1#>
8 :
9 : <cfquery name="insertanswer1" datasource="database">


 

by: trailblazzyr55Posted on 2006-03-09 at 15:04:06ID: 16150268

try this instead, just a few syntax corrections


<cfif FREEPCI eq 0>
AND NOT (TBLNETWORKCARD.TYPE = 'PCI')
<cfelse>
AND TBLNETWORKCARD.TYPE = 'PCI'
</cfif>

<cfif MANUFACTURER eq 'Not Selected'>
<cfelse>
AND (TBLCOMPONENT.MANUFACTURER = '#MANUFACTURER#')
</cfif>

<cfif NETWORKCARDTYPE eq 'Not Selected'>
<cfelse>
AND (TBLCOMPONENT.TYPE = TYPE)
</cfif>

<cfif DATATRANSFERRATE eq 'Not Selected'>
<cfelse>
AND (TBLCOMPONENT.DATATRANSFERRATE >= #DATATRANSFERRATE#)
</cfif>

 

by: LozLaura17Posted on 2006-03-09 at 15:05:58ID: 16150280

Nope still nothing

 

by: mkishlinePosted on 2006-03-10 at 07:07:20ID: 16154883

<cfparam name="form.answer1" default="" />
<cfset session.answer1= #Form.ANSWER1#>

It may also not be a bad idea to add a little javascript validation to your form to ensure that the user enters some value for the answer1 field. There's no place in the code you're posting that could be an endless loop so the problem is likely with the <cflocation url="../RAM.cfm?level=#url.level#&type=#url.type#&name=#url.name#"> page.

 

by: LozLaura17Posted on 2006-03-10 at 07:24:48ID: 16155032

Hi

can u tell me what is wrong in this code. the form field presents the user with a list in a select box. i then only want them to be able to see the submit button when the have selected a value in this list. otherwise do not display the button.  The only issue is that it only seems have an answer value when the form is submitted.

Form field
<select name="ANSWER1" size="5" >
<cfoutput query="processor">
<option value="#processor.COMPID#">#processor.COMPNAME#</option>
</cfoutput>
</select>

Button
<cfparam name="form.answer1" default="" />
<cfset session.answer1= #Form.ANSWER1#>      
<cfif isDefined ("Form.ANSWER1")>
<input name="SUBMIT" type="submit" value="SUBMIT">
<cfelse>
</cfif>

 

by: mkishlinePosted on 2006-03-10 at 07:40:52ID: 16155192

Replace your code with:

<script type="text/javascript">
      function submitOK(selectObj){
            if(selectObj.selectedIndex != 0){
                  document.getElementById('submit').style.display = "";
            }
      }
</script>

<form action="#" method="post">
      <select name="ANSWER1" size="5" onchange="submitOK(this)">
            <cfoutput query="processor">
                  <option value="#COMPID#">#COMPNAME#</option>
                </cfoutput>
      </select>
      <input type="submit" id="submit" name="submit" value="Submit" style="display:none;" />
</form>

Coldfusion does all of it's processing before the information is displayed in the client's browser. Once the information is there, Coldfusion cannot affect the content of the page, to do that you need to use Javascript.

 

by: LozLaura17Posted on 2006-03-10 at 09:04:59ID: 16156391

Thanks for everyones help i have one last problem i want to be able to print, email and send the information to a text file.  i have the text file bit working but there is a problem with outputting it properly.  also i am not sure how to use the information show below and email it and print it.

<!--- Session Information --->
<cfoutput>
<cfsavecontent variable="toPrint">
Date: #DateFormat((now()), "ddd, mmmm dd, yyyy")#
User ID: #url.name#
User Level: #url.level#
User Type: #url.type#
</cfsavecontent>
</cfoutput>

<!--- Selected Components  --->
<cfoutput query="getPC">
Output:#getpc.COMPNAME# x #getpc.NUMBERSELECTED#"
</cfoutput>

<!--- Output to a file  there is a problem here with the second part of this output--->
<cffile action="append" file="C:\Documents and Settings\Laura\Desktop\formlog.txt" addnewline="yes"
output="

<cfoutput>#toPrint#</cfoutput>

<cfoutput query="getPC">
#getpc.COMPNAME# x #getpc.NUMBERSELECTED#
</cfoutput>
">

 

by: mkishlinePosted on 2006-03-10 at 09:18:22ID: 16156517

<cfsavecontent variable="toPrint">
      <cfoutput>
      Date: #DateFormat((now()), "ddd, mmmm dd, yyyy")#
      User ID: #url.name#
      User Level: #url.level#
      User Type: #url.type#
      </cfoutput>

      <cfoutput query="getPC">
      Output:#getpc.COMPNAME# x #getpc.NUMBERSELECTED#"
      </cfoutput>
</cfsavecontent>

<!--- Output to a file  there is a problem here with the second part of this output--->
<cffile action="append" file="C:\Documents and Settings\Laura\Desktop\formlog.txt" addnewline="yes" output="#toPrint#">

<cfmail to="valid@email.address" from="valid@email.address" subject="PC Info">
      #toPrint#
</cfmail>

To print the page, you will probably need to add a redirect to a page that either has javascript that will start the process or just a well-formatted printable display.

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...