• Resolved Andy

    (@andywilmot)


    Hi, I added a filter form using your PHP example a while back. I’m unskilled in PHP, but I managed to get it working and everything was good. I noticed recently however that a keyword search now returns an error. Selecting a dropdown and searching with an empty search box still works correctly. I think the search box might have stopped working when I updated recently to the latest version of PHP. This is the error I’m getting..

    Database Error; SQL: SELECT DISTINCT t.* FROM wp_posts AS t LEFT JOIN wp_postmeta AS discipline ON discipline.meta_key = ‘discipline’ AND discipline.post_id = t.ID WHERE ( ( t.post_title LIKE “%%” OR discipline.meta_value LIKE “%%” ) AND ( t.post_type = “athletes” ) AND ( t.post_status IN ( “publish” ) ) ) AND ( post_title.t LIKE ‘%andrea lee%’ ) ORDER BY t.menu_order ASC, t.menu_order, t.post_title, t.post_date LIMIT 0, 20; Response: Unknown column ‘post_title.t’ in ‘where clause’

    Here is the PHP..

    <?php
    $pod = pods( 'athletes' );
    $keyword = like_escape( pods_v_sanitized( 'keyword', 'post' ) );
    $params = array( 
        'limit' => 20, 
        'orderby' => 'menu_order ASC',
        'where' => 't.post_title LIKE "%' . $keyword . '%" OR discipline.meta_value LIKE "%' . $keyword . '%"'
     );
    //add search filters
     echo $pod->filters( array( 'fields' => array( 'discipline', 'nationality', 'weight_class', 'weight_range', 'level', 'grouping' ), 'label' => ' ' ) );
    //search in athletes pod
    $pod->find( $params );
    // Output the list of the items found
    echo '<ul>';
    // Loop through items found
    while ( $pod->fetch() ) {
    	echo '<div>...</div>';
    }
    echo '</ul>';
    ?>

    I added some stuff to try and fix it, but I keep getting a similar error. Any ideas what I’m missing?

    • This topic was modified 3 years, 6 months ago by Andy.

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Filter form keyword search is throwing an error’ is closed to new replies.