Title: Warning: Invalid argument
Last modified: August 20, 2016

---

# Warning: Invalid argument

 *  [Alphaz74](https://wordpress.org/support/users/alphaz74/)
 * (@alphaz74)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/warning-invalid-argument-3/)
 * Warning: Invalid argument supplied for foreach() in /home/XXXX/public_html/wp-
   content/plugins/donation-thermometer/donation_therm.php on line 418
 * Warning: imagepng() [function.imagepng]: Unable to open ‘/home/XXXX/public_html/
   wp-content/plugins/donation-thermometer/therm_118_886.40_32256.png’ for writing:
   Permission denied in /home/XXXX/public_html/wp-content/plugins/donation-thermometer/
   donation_therm.php on line 319
 * Warning: imagecreatefrompng(/home/XXXX/public_html/wp-content/plugins/donation-
   thermometer/therm_118_886.40_32256.png) [function.imagecreatefrompng]: failed
   to open stream: No such file or directory in /home/XXXX/public_html/wp-content/
   plugins/donation-thermometer/donation_therm.php on line 354
 * Warning: imagecopyresampled() expects parameter 2 to be resource, boolean given
   in /home/XXXX/public_html/wp-content/plugins/donation-thermometer/donation_therm.
   php on line 359
 * Warning: imagepng() [function.imagepng]: Unable to open ‘/home/XXXX/public_html/
   wp-content/plugins/donation-thermometer/therm_118_886.40_32256_350.png’ for writing:
   Permission denied in /home/XXXX/public_html/wp-content/plugins/donation-thermometer/
   donation_therm.php on line 360
 * Warning: imagecreatefrompng(/home/XXXX/public_html/wp-content/plugins/donation-
   thermometer/therm_118_886.40_32256.png) [function.imagecreatefrompng]: failed
   to open stream: No such file or directory in /home/XXXX/public_html/wp-content/
   plugins/donation-thermometer/donation_therm.php on line 354
 * Warning: imagecopyresampled() expects parameter 2 to be resource, boolean given
   in /home/XXXX/public_html/wp-content/plugins/donation-thermometer/donation_therm.
   php on line 359
 * Warning: imagepng() [function.imagepng]: Unable to open ‘/home/XXXX/public_html/
   wp-content/plugins/donation-thermometer/therm_118_886.40_32256_350.png’ for writing:
   Permission denied in /home/XXXX/public_html/wp-content/plugins/donation-thermometer/
   donation_therm.php on line 360
 * [http://wordpress.org/extend/plugins/donation-thermometer/](http://wordpress.org/extend/plugins/donation-thermometer/)

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

 *  Thread Starter [Alphaz74](https://wordpress.org/support/users/alphaz74/)
 * (@alphaz74)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/warning-invalid-argument-3/#post-3348514)
 * I get the error below when trying to save the settings
 * arning: Invalid argument supplied for foreach() in /home/XXXX/public_html/wp-
   content/plugins/donation-thermometer/donation_therm.php on line 190
 *  Plugin Author [rhewlif](https://wordpress.org/support/users/henryp/)
 * (@henryp)
 * [13 years, 5 months ago](https://wordpress.org/support/topic/warning-invalid-argument-3/#post-3348660)
 * The errors are coming up because the plugin is trying to delete/write files, 
   but can’t. I suggest changing the permissions of the plugin folder to 777 (no
   need to recurse into subdirectories) and see how that goes.
 * Sorry for the late reply, but am back in the UK now.
 *  [jdaviescoates](https://wordpress.org/support/users/jdaviescoates/)
 * (@jdaviescoates)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/warning-invalid-argument-3/#post-3348671)
 * I have a similar problem:
 * > Warning: Invalid argument supplied for foreach() in /wp-content/plugins/donation-
   > thermometer/donation_therm.php on line 231
 * I don’t really to have 777 permission anywhere in my install but I tried making
   the plugin folder 777 it temporarily to see if it would solve the issue. It did
   not.
 * Please help.
 * Thanks,
 * Josef.
 *  Plugin Author [rhewlif](https://wordpress.org/support/users/henryp/)
 * (@henryp)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/warning-invalid-argument-3/#post-3348673)
 * Hi Josef,
 * The error message you are getting is for a different function in the plugin (
   presumably you’re using the latest version?) so the solution on this thread won’t
   likely work. Here on line 231, when the plugin settings get updated all previous
   thermometer images are deleted from the plugin folder. I can’t replicate the 
   error message you are getting, but I suspect it may be because the glob function
   is returning an empty array. Can you edit the donation_therm.php file and replace
   lines 230-234
 *     ```
       if( isset($_GET['settings-updated']) ) {
           foreach(glob(THERM_ABSPATH.'*.png*') as $v){
           unlink($v);}
       }
       ```
   
 * with:
 *     ```
       if( isset($_GET['settings-updated']) ) {
           $therms = glob(THERM_ABSPATH.'*.png');
           if (is_array($therms) && count($therms) > 0){
       	foreach($therms as $v){
       	    unlink($v);}
           }
       }
       ```
   
 * Please also make sure the plugin folder is readable. Do you still get the error
   message once you have created thermometers on a page or post?

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

The topic ‘Warning: Invalid argument’ is closed to new replies.

 * ![](https://ps.w.org/donation-thermometer/assets/icon-256x256.png?rev=3197594)
 * [Donation Thermometer](https://wordpress.org/plugins/donation-thermometer/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/donation-thermometer/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/donation-thermometer/)
 * [Active Topics](https://wordpress.org/support/plugin/donation-thermometer/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/donation-thermometer/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/donation-thermometer/reviews/)

 * 4 replies
 * 3 participants
 * Last reply from: [rhewlif](https://wordpress.org/support/users/henryp/)
 * Last activity: [13 years, 3 months ago](https://wordpress.org/support/topic/warning-invalid-argument-3/#post-3348673)
 * Status: not resolved