• Resolved gmisura

    (@gmisura)


    I installed v1.5.4.9 on my WP 4.1 site.
    I then deleted all the fields except email.
    When I put the shortcode on my page, I got the error in the log:

    [31-Dec-2014 00:06:48 America/Chicago] WordPress database error Incorrect parameter count in the call to native function 'FIELD' for query SELECT f.id FROM wp_participants_database_fields f WHERE f.name IN ("email") ORDER BY FIELD("email") made by require('wp-blog-header.php'), require_once('wp-includes/template-loader.php'), include('/themes/twentyfifteen/page.php'), get_template_part, locate_template, load_template, require('/themes/twentyfifteen/content-page.php'), the_content, apply_filters('the_content'), call_user_func_array, do_shortcode, preg_replace_callback, do_shortcode_tag, call_user_func, wpmem_shortcode, do_shortcode, preg_replace_callback, do_shortcode_tag, call_user_func, Participants_Db::print_signup_form, Participants_Db::print_signup_class_form, PDb_Signup::print_form, PDb_Signup->__construct, PDb_Shortcode->_print_from_template, PDb_Signup->_include_template, include('/plugins/participants-database/templates/pdb-signup-default.php'), PDb_Signup->print_form_head, PDb_Shortcode->_print_form_head, PDb_Base::get_field_indices

    When I submit the form, I get an error:

    [31-Dec-2014 06:11:28 UTC] WordPress database error Incorrect parameter count in the call to native function 'FIELD' for query SELECT f.name FROM wp_participants_database_fields f WHERE f.id IN ("") ORDER BY FIELD("") made by require('wp-blog-header.php'), require_once('wp-load.php'), require_once('wp-config.php'), require_once('wp-settings.php'), do_action('init'), call_user_func_array, Participants_Db::init, Participants_Db::process_page_request, PDb_Base::get_shortcode_columns, PDb_Base::get_field_indices

    and the email is not saved to the db.

    This is on a vagrantpress VM.

    https://www.ads-software.com/plugins/participants-database/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter gmisura

    (@gmisura)

    For my purpose, I removed I updated:

    participants-database/classes/PDb_Base.class.php

    I just removed the ‘ORDER BY’ clause from

    $sql = 'SELECT f.' . ($indices ? 'id' : 'name') . ' FROM ' . Participants_Db::$fields_table . ' f WHERE f.' . ($indices ? 'name' : 'id') . ' IN ("' . implode('","',$fieldnames) . '")';

    Not sure what you were expecting the FIELD’s function to do…

    Doco at:
    https://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_field

    says

    Returns the index (position) of str in the str1, str2, str3, … list. Returns 0 if str is not found.

    Maybe you just can remove “FIELD” and let the “ORDER BY” be followed by the implode call?

    Plugin Author xnau webdesign

    (@xnau)

    I’ll have to look into this. I’ve never tried to run the plugin with just one field, I’m assuming the bug is related that that. I would suggest adding another field or two (even if you’re not using them) to see if that solves the issue.

    The FIELD function is necessary to order the query result using the value of a column.

    Thanks very much for the report.

    Thread Starter gmisura

    (@gmisura)

    The FIELD is not necessary. FIELD returns a number…

    I think you have the wrong function.

    https://dev.mysql.com/doc/refman/5.0/en/sorting-rows.html

    Plugin Author xnau webdesign

    (@xnau)

    Well, the function is correct, but I see I made an error in not including the first term. The order clause is supposed to be something like:

    ORDER BY FIELD(f.name, "email")

    It’s purpose is to put the query results in the same order as the field names in the “fields” attribute in the shortcode.

    So, the code on line 529 of PDb_Base.class.php should be:

    $sql = 'SELECT f.' . ($indices ? 'id' : 'name') . ' FROM ' . Participants_Db::$fields_table . ' f WHERE f.' . ($indices ? 'name' : 'id') . ' IN ("' . implode('","',$fieldnames) . '") ORDER BY FIELD( f.name, "' . implode('","',$fieldnames) . '")';

    Thanks for pointing this out.

    Thread Starter gmisura

    (@gmisura)

    That makes more sense.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Incorrect parameter count in the call to native function 'FIELD' for query’ is closed to new replies.