I am working on a ngo PROJECT. I prepared some stuff on my localhost and now uploaded to our test server. But when I try to open wp-admin of my wordpress, I get following warnings.
Warning: Invalid argument supplied for foreach() in /home/zooliepd/public_html/clients/sparsha/wp-includes/post.php on line 3589
Warning: Cannot modify header information - headers already sent by (output started at /home/zooliepd/public_html/clients/sparsha/wp-includes/post.php:3589) in /home/zooliepd/public_html/clients/sparsha/wp-includes/pluggable.php on line 876
In my website I made posts page to my home page.
I tried to put ob_start(): in my header file but it didn't work! and no spaces are there in post file at given line number.
Plz help me
Warning: Invalid argument supplied for foreach() in /home/zooliepd/public_html/clients/sparsha/wp-includes/post.php on line 3589
It is because foreach expects a array there, do like below :
if(is_array($your_arry)){
foreach(){....}
}
put your foreach inside this condition
If first warning is fixed the second will go automatically, because second one caused because of first. :D
Related
The company I work for are using Customer Area for one of our clients and everything has been great until recently. When a private file is tried to be downloaded we get several error messages appear:
Notice: Undefined index: force-download in /Users/mathew/Websites/mamp/portal-test/wp-content/plugins/customer-area/src/php/core-addons/private-file/private-file-addon.class.php on line 1029
Warning: Cannot modify header information - headers already sent by (output started at /Users/mathew/Websites/mamp/portal-test/wp-content/plugins/customer-area/src/php/core-addons/private-file/private-file-addon.class.php:1029) in /Users/mathew/Websites/mamp/portal-test/wp-content/plugins/customer-area/src/php/core-addons/private-file/private-file-default-handlers.class.php on line 945
Warning: Cannot modify header information - headers already sent by (output started at /Users/mathew/Websites/mamp/portal-test/wp-content/plugins/customer-area/src/php/core-addons/private-file/private-file-addon.class.php:1029) in /Users/mathew/Websites/mamp/portal-test/wp-content/plugins/customer-area/src/php/core-addons/private-file/private-file-default-handlers.class.php on line 952
Warning: Cannot modify header information - headers already sent by (output started at /Users/mathew/Websites/mamp/portal-test/wp-content/plugins/customer-area/src/php/core-addons/private-file/private-file-addon.class.php:1029) in /Users/mathew/Websites/mamp/portal-test/wp-content/plugins/customer-area/src/php/core-addons/private-file/private-file-default-handlers.class.php on line 955
Warning: Cannot modify header information - headers already sent by (output started at /Users/mathew/Websites/mamp/portal-test/wp-content/plugins/customer-area/src/php/core-addons/private-file/private-file-addon.class.php:1029) in /Users/mathew/Websites/mamp/portal-test/wp-content/plugins/customer-area/src/php/core-addons/private-file/private-file-default-handlers.class.php on line 956
Warning: Cannot modify header information - headers already sent by (output started at /Users/mathew/Websites/mamp/portal-test/wp-content/plugins/customer-area/src/php/core-addons/private-file/private-file-addon.class.php:1029) in /Users/mathew/Websites/mamp/portal-test/wp-content/plugins/customer-area/src/php/core-addons/private-file/private-file-default-handlers.class.php on line 959
Warning: Cannot modify header information - headers already sent by (output started at /Users/mathew/Websites/mamp/portal-test/wp-content/plugins/customer-area/src/php/core-addons/private-file/private-file-addon.class.php:1029) in /Users/mathew/Websites/mamp/portal-test/wp-content/plugins/customer-area/src/php/core-addons/private-file/private-file-default-handlers.class.php on line 960
Warning: Cannot modify header information - headers already sent by (output started at /Users/mathew/Websites/mamp/portal-test/wp-content/plugins/customer-area/src/php/core-addons/private-file/private-file-addon.class.php:1029) in /Users/mathew/Websites/mamp/portal-test/wp-content/plugins/customer-area/src/php/core-addons/private-file/private-file-default-handlers.class.php on line 961
Warning: Cannot modify header information - headers already sent by (output started at /Users/mathew/Websites/mamp/portal-test/wp-content/plugins/customer-area/src/php/core-addons/private-file/private-file-addon.class.php:1029) in /Users/mathew/Websites/mamp/portal-test/wp-content/plugins/customer-area/src/php/core-addons/private-file/private-file-default-handlers.class.php on line 989
When trying to reset the plugin settings or database through the plugin we also get the error:
Notice: Undefined index: cuar_admin_theme_url in /Users/mathew/Websites/mamp/portal-test/wp-content/plugins/customer-area/src/php/core-classes/settings.class.php on line 674
Warning: Cannot modify header information - headers already sent by (output started at /Users/mathew/Websites/mamp/portal-test/wp-content/plugins/customer-area/src/php/core-classes/settings.class.php:674) in /Users/mathew/Websites/mamp/portal-test/wp-includes/pluggable.php on line 1216
We are using our own WordPress theme which we have removed all customised WP Customer Area templates, and even switched themes to TwentySeventeen but the errors still appear. As well as switching themes we have tried uninstalling and reinstalling the plugin.
So we decided to create a new blank WordPress environment and test it there and re-download the plugin so it is new. The download button then began to work but when testing for a second/third time the errors returned.
As previously mentioned the plugin was working perfectly up until being discovered yesterday. We haven’t edited any of the core files only the template files which we did by following the instructions of WP Customer Area. The site is running WordPress 4.9.1 and plugin version is 7.4.5. However, we have tried with Wordpress 4.9 and plugin versions 7.4.0, 7.3.0.
If anyone can help with this it would be greatly appreciated. Thank you for taking the time to read my message.
Thanks
I got in touch with the people at WP Customer Area and they are looking into the issue as it seems to be a bug in the plugin. But in the meantime they have given me some code to stop the errors by replacing:
!isset($_GET['force-download']) && $_GET['force-download'] != 1)
On line 1029 in customer-area/src/php/core-addons/private-file/private-file-addon.class.php.
with the line:
if ( !isset($_GET['force-download']) || (isset($_GET['force-download']) && $_GET['force-download'] !== 1))
This has helped me with the errors and hope it helps you guys as well.
Unfortunately you will probably need to chase this bug through a lot of code, but the general fix is to identify situations where an array key is assumed to be existing and fix it with some code.
The error tells you where to start:
Notice: Undefined index: force-download in /Users/mathew/Websites/mamp/portal-test/wp-content/plugins/customer-area/src/php/core-addons/private-file/private-file-addon.class.php on line 1029
From the index name, force-download I would guess this is the value of a checkbox on an HTML form. When unchecked, no value is passed via HTTP POST yet the script is looking for this in $_POST (guessing here).
The best advice I can give is to fix the instances of this with something like:
<?PHP
if( array_key_exists( 'force-download', $_POST ) && $_POST['force-download'] )
{
// do something
}
?>
What I do for my forms:
In order to always have a $_POST value, I output a hidden form field with a zero value before the checkbox field. Then the checkbox field has a value of 1. That way the checkbox field, if checked, passes '1' via $_POST and my if statements just work without having to always be constantly be checking for empty, array_key_exists, etc.
I'm currently running with PHP 5.3.4. I found that this should be compatible here https://joomla.stackexchange.com/questions/786/what-is-the-maximum-version-of-php-that-joomla-1-5-will-run
However I did have some PHP issues that I resolved with this link: Joomla menu not showing
After doing this I was able to see the menu items show up correctly for my site. However in the Menu Item Manager inside the Joomla admin the errors listed below are thrown when debugged. Menu items will not display at all and the list is blank. What is causing these errors to be thrown and not display my menu items in the Joomla Admin yet display on the website perfectly?
Warning: Parameter 4 to JHTMLMenu::treerecurse() expected to be a reference, value given in D:\Inetpub\wwwroot\libraries\joomla\html\html.php on line 87
Warning: array_slice() expects parameter 1 to be array, null given in D:\Inetpub\wwwroot\administrator\components\com_menus\models\list.php on line 143
Warning: Invalid argument supplied for foreach() in D:\Inetpub\wwwroot\administrator\components\com_menus\models\list.php on line 147 Notice: Only variable references should be returned by reference in D:\Inetpub\wwwroot\administrator\components\com_menus\views\list\view.php on line 198
Warning: Invalid argument supplied for foreach() in D:\Inetpub\wwwroot\administrator\components\com_menus\views\list\view.php on line 66
Sorry, what Joomla 1.5 version do you have?
Remember that only the 1.15.16+ are PHP 5.3 compatible
Look this Post Joomla 1.5 and PHP 5.3 with the same error on line:
libraries\joomla\html\html.php on line 87
I think that you can try to replace the files with error with PhilETaylor version https://github.com/PhilETaylor/Joomla1.5.999
good Luck!
Credit to Ciro, by replacing the following files in my case resolved my issue. There was not a need to replace all Joomla files.
helper.php - found here modules\mod_mainmenu
html.php - found here libraries\joomla\html
view.php - found here administrator\components\com_menus\views\list
Not sure when this occurred but when editing a category, this error is given at the top of the edit category page.
Warning: call_user_func_array() expects parameter 1 to be a valid
callback, function 'my_category_custom_fields' not found or invalid
function name in /home2/sirenon2/public_html/wp-includes/plugin.php on
line 525
Line 525 is call_user_func_array($the_['function'], array_slice($args, 0, (int) $the_['accepted_args']));
When I submit on the edit category page, it gives me the original error plus:
Warning: Cannot modify header information - headers already sent by
(output started at
/home2/sirenon2/public_html/wp-includes/plugin.php:525) in
/home2/sirenon2/public_html/wp-includes/pluggable.php on line 1228
Line 1228 is header("Location: $location", true, $status);.
Any ideas on what the problem is and how to fix it? I do have custom fields on my edit category pages.
Thanks
Either one of installed plugins has error which is throwing above error or you need to update wordpress or PHP. There may be compatibility issue of WordPress with installed PHP version. Few of WordPress's functions might have been updated.
If updating doesn't works, simply go to wp-config.php file and set this constant to false. If this line is not there into config file, add it.
define('WP_DEBUG', false);
I also have this problem before. But I change output_buffering to On. You can find it from PHP.ini.
Or refer this url http://chevronscode.com/index.php/wordpress-header-error-wp-includespluggable-php.html
I am having this error on my wp multi site ,
Warning: Missing argument 2 for PLATFORMS::get_device_info(), called in /homepages/13/d133448570/htdocs/sogolearn/prosper/tracking202/redirect/rtr.php on line 395 and defined in /homepages/13/d133448570/htdocs/sogolearn/prosper/202-config/connect2.php on line 258
Warning: Cannot modify header information - headers already sent by (output started at /homepages/13/d133448570/htdocs/sogolearn/prosper/202-config/connect2.php:258) in /homepages/13/d133448570/htdocs/sogolearn/prosper/tracking202/redirect/rtr.php on line 286
Page url = http://prosper.sogolearn.com/tracking202/redirect/rtr.php?t202id=8368&t202kw=
Rest of the functions are working properly, no errors on the main site or other domains.
I have no idea what is this error and How to fix it.
The first error is caused by only providing one argument to a function or method that requires at least two arguments. For example, if we have a function like this:
function hasTwoArguments($first, $second) {
// Do something...
}
...then the error occurs if it is called like this:
// The second argument is required, but is not provided, causing an error
hasTwoArguments('first');
The second error is most likely a side-effect of the first error. HTTP headers must be set before any output is sent to the client (the browser in this case). The first error outputs a message (describing what went wrong), which is why the second error occurred.
To fix these errors you have to make sure that the PLATFORMS::get_device_info() method gets two arguments. If you have written the code yourself then you can either provide the second argument, or you can make the second argument optional (if it indeed is optional). If you did not write the code yourself then you should contact the author(s) of the code, telling them that they may have made a mistake.
I am trying to rename the menu items in v tiger crm. I googled but I could not get the right information. I try to change the menu items and getting the following warnings.
'contacts'=>'customers' in include/language/en_us.lang.php
Warning: Cannot modify header information - headers already sent by (output started at ``vtigercrm/include/language/en_us.lang.php:1) in vtigercrm/index.php on line 606
Warning: Cannot modify header information - headers already sent by (output started at ``/vtigercrm/include/language/en_us.lang.php:1) in vtigercrm/index.php on line 608
Warning: Cannot modify header information - headers already sent by (output started ``at/vtigercrm/include/language/en_us.lang.php:1) in vtigercrm/index.php on line 610
use
ob_start (); and ob_flush();
in your index.php and en_us.lang.php pages the problem will solve.
1- that error states there is a blank line before the opening php statement or 2- you may save en_us.lang.php in utf8 format.
solution:
for 1: remove any extra line(s) before <?php and Also after ?> at the beginning and the end of
mentioned file. for 2: use notepad++ to convert encoding to
UTF8 without BOM and then save it.