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.

{sgement_3} not working in {exp:query}

March 20, 2009 10:10am

Subscribe [3]
  • #1 / Mar 20, 2009 10:10am

    CimexMedia

    68 posts

    Hello
    this is really strange, I use {segment_3} to parameterize a query (I use exp:query to get the pagination for free). It mostly works but when {segment_3} equals ‘N’ or ‘O’ I get a PHP syntax error !!

    {exp:query limit="15" paginate="both" sql="
            SELECT t.entry_id as supplier_id, t.title as supplier_name, t.url_title as supplier_url_title, t.entry_id as supplier_id, 
            d.field_id_108 as supplier_logo, d.field_id_13 as supplier_address1,d.field_id_34 as supplier_address2,d.field_id_35 as supplier_town,
            d.field_id_37 as supplier_county,d.field_id_36 as supplier_postal_code,d.field_id_38 as supplier_country, d.field_id_14 as supplier_telephone, 
            d.field_id_15 as supplier_fax, d.field_id_16 as supplier_email, d.field_id_17 as supplier_website1, d.field_id_12 as supplier_profile
            FROM exp_weblog_data as d, exp_weblog_titles as t
            WHERE t.weblog_id = '8' 
            AND t.site_id = '1' 
            AND t.entry_id = d.entry_id 
            AND t.title REGEXP '^{segment_3}' 
            ORDER BY t.title ASC
            "}

    Any ideas on how to work around this ?

    Thanks

  • #2 / Mar 20, 2009 11:50am

    Ingmar

    29245 posts

    Does the same thing happen when you use hard-coded values of N or O? Also, what version and build of EE are you on?

  • #3 / Mar 20, 2009 12:40pm

    CimexMedia

    68 posts

    yes, and funnily enough, it also happens if I replace

    REGEXP '^N'

    by

    LIKE 'N%'

    but again only for the letters N and O.


    My version of EE is 1.6.4

    thanks

  • #4 / Mar 20, 2009 3:47pm

    Sue Crocker

    26054 posts

    If you do the same query in PHPMyAdmin, do you get the same error message? Using LIKE ‘N%’ ?

  • #5 / Mar 20, 2009 4:31pm

    CimexMedia

    68 posts

    I found what the problem was, I was calling a PHP function to generate a CSS class inside some HTML inside the {exp:query} tags
    For some reason I don’t understand PHP choked on it but only for these 2 letters (strange uh ?)
    Removing the function call fixed it

    Thanks anyway

  • #6 / Mar 20, 2009 5:07pm

    Sue Crocker

    26054 posts

    Glad you were able to find out what the problem was. Don’t hesitate to post again if needed.

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

ExpressionEngine News!

#eecms, #events, #releases