Title: Undefined variable: query_params on form submit
Last modified: December 1, 2016

---

# Undefined variable: query_params on form submit

 *  Resolved [kellybleck](https://wordpress.org/support/users/kellybleck/)
 * (@kellybleck)
 * [9 years, 6 months ago](https://wordpress.org/support/topic/undefined-variable-query_params-on-form-submit/)
 * In addition to the error talked about in previous threads, I’m also getting
    `
   Notice: Undefined variable: query_params in /home/alexiusllc/public_html/wp-content/
   plugins/mailchimp/lib/mailchimp/mailchimp.php on line 34`
 * I just set `$query_params = '';` on Line 1, but am not sure if that’s the correct
   solution.
 * Help?

Viewing 3 replies - 1 through 3 (of 3 total)

 *  [mcsupport](https://wordpress.org/support/users/mcsupport/)
 * (@mcsupport)
 * [9 years, 6 months ago](https://wordpress.org/support/topic/undefined-variable-query_params-on-form-submit/#post-8507391)
 * Hey there [@kellybleck](https://wordpress.org/support/users/kellybleck/),
 * Thanks for getting in touch and providing those specifics. Just to make sure 
   we’re digging into this thoroughly, would you mind providing a few specific details
   so we’re fully up to speed on the situation?
 * – Would you be able to provide the URL of where this form is currently accessible
   for testing?
    – What theme is being used on the site? – What other plugins are
   currently active on the site? – What version of PHP is running on the site? –
   In addition to this error’s text, would it be possible to share a screenshot 
   of how this error appears within the context of the site?
 * Thanks so much in advance for these details. We’ll keep an eye out for your response.
 * Best,
    Malachite
 *  [Jer Clarke](https://wordpress.org/support/users/jeremyclarke/)
 * (@jeremyclarke)
 * [9 years, 4 months ago](https://wordpress.org/support/topic/undefined-variable-query_params-on-form-submit/#post-8665716)
 * Hey [@mcsupport](https://wordpress.org/support/users/mcsupport/), did you look
   at the code Kelly was talking about? There’s an obvious PHP error that anyone
   who uses WP_DEBUG would understand immediately.
 * You don’t have to ask for more information, just look at the code, then fix the
   problem on your end! She even provided the solution for you!
 * Here’s the code ([…] stands in for other stuff that wasn’t important to the problem):
 *     ```
       public function get($endpoint, $count = 10, $fields = array())
           {
               $url = $this->api_url . $endpoint;
   
               if ($count) {
                   $query_params = 'count=' . $count . '&';
               }
       [...]
               $query_params .= $field . '=' . $value . '&';
       ```
   
 * Why do we get the error?:
 * > Notice: Undefined variable: query_params in …/plugins/mailchimp/lib/mailchimp/
   > mailchimp.php on line 34
 * We get it because you never initialize the variable safely. The first use, with
   a bare “=” is inside an IF statement, so if there’s no $count value, then it 
   doesn’t get run. Then when you subsequently add to $query_params with “.=” the
   error shows up, because “.=” means “add to this variable” and PHP gets made if
   the variable doesn’t exist.
 * This should have been obvious from the bug report above. It’s a common mistake
   that’s easy to fix.
 * This bug is directly related to the WP_DEBUG stuff I explained in detail in this
   thread:
 * [https://wordpress.org/support/topic/mailchimp_widgetphp-littered-with-php-undefined-index-notices/](https://wordpress.org/support/topic/mailchimp_widgetphp-littered-with-php-undefined-index-notices/)
 * If you can find MC_Nate and have him take a look at this issue that would be 
   great, it seems your goal of increasing testing quality isn’t going exactly to
   plan.
 * Please fix this by adding a line with
 * `$query_params = '';`
 * Above the line with `if ($count)`
    -  This reply was modified 9 years, 4 months ago by [Jer Clarke](https://wordpress.org/support/users/jeremyclarke/).
 *  [mcsupport](https://wordpress.org/support/users/mcsupport/)
 * (@mcsupport)
 * [9 years, 4 months ago](https://wordpress.org/support/topic/undefined-variable-query_params-on-form-submit/#post-8674056)
 * Hey [@kellybleck](https://wordpress.org/support/users/kellybleck/) and [@jeremyclarke](https://wordpress.org/support/users/jeremyclarke/),
 * We appreciate you guys chiming in here with those details. I apologize for the
   frustration here and I’m happy to let everyone know that a fix was pushed for
   this issue today. Please update your plugin version to 1.5.7 and let us know 
   if you run into any issues after the update.
 * Thanks again!
 * Pearl

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Undefined variable: query_params on form submit’ is closed to new replies.

 * ![](https://ps.w.org/mailchimp/assets/icon.svg?rev=3156997)
 * [Mailchimp List Subscribe Form](https://wordpress.org/plugins/mailchimp/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/mailchimp/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/mailchimp/)
 * [Active Topics](https://wordpress.org/support/plugin/mailchimp/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/mailchimp/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/mailchimp/reviews/)

 * 3 replies
 * 3 participants
 * Last reply from: [mcsupport](https://wordpress.org/support/users/mcsupport/)
 * Last activity: [9 years, 4 months ago](https://wordpress.org/support/topic/undefined-variable-query_params-on-form-submit/#post-8674056)
 * Status: resolved