Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7608881
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T01:02:05+00:00 2026-05-31T01:02:05+00:00

My goal is to just output the column data specified in the fieldList. Getting

  • 0

My goal is to just output the column data specified in the “fieldList”.

Getting the following error:

Complex object types cannot be converted to simple values. The expression has requested a variable or an intermediate expression result as a simple value, however, the result cannot be converted to a simple value. Simple values are strings, numbers, boolean values, and date/time values. Queries, arrays, and COM objects are examples of complex values. The most likely cause of the error is that you are trying to use a complex value as a simple one. For example, you might be trying to use a query variable in a cfif tag. The error occurred on line 20.

When trying to do the following:

<cfquery datasource="retailers" name="myQuery">
Select * FROM retailer 
WHERE retailer_id = '#url.id#'
</cfquery>

<cfset fieldList = "company,phone,phone_secondary,fax,email,website">
<cfloop list="#fieldList#" index="i">      
#myQuery[i]#
</cfloop>

Shouldn’t this work without giving me an error? I feel like I’m just overlooking something simple I just can’t find the answer anywhere.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T01:02:06+00:00Added an answer on May 31, 2026 at 1:02 am

    Ok, I see you ammended your initial code, so here’s my response:

    You are looping over a list of columns, and trying to evaluate each column as though it is a single element in a struct.

    A query, however, is slightly different: it is accessed as a series of structs, which in turn, are arrays–of each row of data as they return from the query.

    If you want to output all of the rows of data, without knowing the columns up front (or passing them in dynamically as you are implying in your code above), try this:

    <cfoutput query="myQuery">
      <cfloop list="#myQuery.ColumnList#" index="thisColumn">
        #myQuery[thisColumn][myQuery.CurrentRow]#
      </cfloop>
    </cfoutput>
    

    This will provide you with the output you need. The outer cfoutput with the query attribute will loop over all the rows of data you received. Then, for each row, you loop over the list of columns the query produces, and for each column, output the data, specifying the row via myQuery.CurrentRow, which iterates automatically for you via the outer output.

    I’d also take a moment now to advocate that you try to stay away from loops within loops, and just output your values explicitly:

    <cfoutput query="myQuery">
      #company# #phone#
    </cfoutput>
    

    Using this syntax is slightly less expensive than the aforementioned loop within a loop.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just started to develop a new module in Drupal. The goal of the
Goal : Our application is built using multiple types (e.g. Person, PersonSite(ICollection), Site -
Goal : After user saves data to my mysql DB, a JSON teaser of
My goal is to have all object files built in a .objs directory instead
I have an assignment in C++ and I'm having trouble getting started. The goal
Goal: Best system for refactoring complex & ugly code in exactly the same file.
The overall program is too complex to display here. Basically, just pay attention to
Goal I was trying to get jQuery to output the class name of the
This is essentially very simple I've just been rather verbose about it. My data
Just as a demo, try the following code: <?php echo '<pre>'; ob_end_flush(); for($i=0;$i<2;$i++) {

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.