ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Basic Query Module functionality not working

August 31, 2009 11:45am

Subscribe [3]
  • #1 / Aug 31, 2009 11:45am

    philfreo

    50 posts

    I’ve got a full version of EE 1.6.8 (build 20090723) installed, the Query module activated, yet the basic functionality is not working for me.  My template is simply:

    {exp:query sql="SELECT cat_id FROM exp_categories"}
    {cat_id}
    
    {if no_results}no results!{/if}
    {exp:query}

    Yet the page outputs:

    {cat_id}

    rather than the actual cat_id’s from the database.

    I know that the Query module is at least somewhat working because I edited mod.query.php (for testing) after line 182 and added:

    print_r($query);

    And on the outputted template I do indeed get the full result set.

    DB_Cache Object
    (
        [result] => Array
            (
                [0] => Array
                    (
                        [cat_id] => 4
                    )
    
                [1] => Array
                    (
                        [cat_id] => 5
                    )
    
                [2] => Array
                    (
                        [cat_id] => 6
                    )
    
                [3] => Array
                    (
                        [cat_id] => 7
                    )
    
                [4] => Array
                    (
                        [cat_id] => 8
                    )
    
                [5] => Array
                    (
                        [cat_id] => 9
                    )
    
                [6] => Array
                    (
                        [cat_id] => 10
                    )
    
            )
    
        [row] => Array
            (
                [cat_id] => 4
            )
    
        [num_rows] => 7
        [q_count] => 18
        [fields] => Array
            (
            )
    
    )

    What could be stopping the template tags from being parsed correctly?  I’ve got no other problems with tags on the rest of my site.

  • #2 / Aug 31, 2009 12:19pm

    Sue Crocker

    26054 posts

    First things first. How about upgrading your version of EE? You’re quite a few builds behind.

  • #3 / Aug 31, 2009 12:28pm

    philfreo

    50 posts

    First things first. How about upgrading your version of EE? You’re quite a few builds behind.

    That was a typo.  I’m running the latest build of 1.6.8.

  • #4 / Aug 31, 2009 1:18pm

    Derek Jones

    7561 posts

    You’re missing the forward slash from your closing tag:

    {exp:query sql="SELECT cat_id FROM exp_categories"}
    {cat_id}
    
    {if no_results}no results!{/if}
    {exp:query}

    Should be (notice the last line):

    {exp:query sql="SELECT cat_id FROM exp_categories"}
    {cat_id}
    
    {if no_results}no results!{/if}
    {/exp:query}
  • #5 / Aug 31, 2009 2:04pm

    philfreo

    50 posts

    You’re missing the forward slash from your closing tag:

    {exp:query sql="SELECT cat_id FROM exp_categories"}
    {cat_id}
    
    {if no_results}no results!{/if}
    {exp:query}

    Should be (notice the last line):

    {exp:query sql="SELECT cat_id FROM exp_categories"}
    {cat_id}
    
    {if no_results}no results!{/if}
    {/exp:query}

    Wow, duh!  This was driving me crazy.  I knew it had to be something stupid but sometimes it takes a second pair of eyes.  Thanks!

    It would be nice for EE to output some error message if basic parsing fails.

  • #6 / Aug 31, 2009 2:33pm

    Derek Jones

    7561 posts

    If you turn on the Template Debugging (Output and Debugging Preferences) you would indeed get such a message, e.g.:

    (0.013598) Tag: {exp:query sql="SELECT cat_id FROM exp_categories"}
    (0.013719) No Closing Tag
    (0.013776) Tag: {exp:query}
    (0.013816) No Closing Tag

  • #7 / Aug 31, 2009 2:36pm

    philfreo

    50 posts

    If you turn on the Template Debugging (Output and Debugging Preferences) you would indeed get such a message, e.g.:

    (0.013598) Tag: {exp:query sql="SELECT cat_id FROM exp_categories"}
    (0.013719) No Closing Tag
    (0.013776) Tag: {exp:query}
    (0.013816) No Closing Tag

    Excellent, thanks.

  • #8 / Aug 31, 2009 2:49pm

    Derek Jones

    7561 posts

    Glad to help, Phil!

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases