Basically you've woken up this morning, visited your website, and all your K2 articles are gone !!!!

If you login to your Joomla! administration panel (back-end) and look under k2 items, you should get the following error:

  1.  Warning: Invalid argument supplied for foreach() in /home/public_html/administrator/components/com_k2/views/items/tmpl/default.php on line 80 

If I went to K2 Comments, I'd get an additional error:


  1.  Warning: Invalid argument supplied for foreach() in /home/public_html/administrator/components/com_k2/views/items/tmpl/default.php on line 80 
  3.  Warning: Invalid argument supplied for foreach() in /home/public_html/administrator/components/com_k2/views/comments/tmpl/default.php on line 145 
So I checked these pages and the error is at a foreach() line where it's pulling data from the database.  I asked to see the jos_k2_items table and it returned the following error:
  1.  #145 - Table './jos_k2_items' is marked as crashed and should be repaired 
The Quick Fix
I managed to fix this with this SQL command .  Note: you need to be able to run SQL commands against your database.  My client had phpMyAdmin installed so I click on "jos_k2_items" table and then click on the "SQL" tab
Type the following query:
  1.  REPAIR TABLE jos_k2_items 



Note that I say "jos_k2_items" because by default that's what it is... If you changed the table prefix when you installed Joomla! on your site (default is "jos_") then you'll need to change this repair table command to match the database table where your K2 articles are stored (eg. "zu1fq_k2_items").


0 newseason Thursday, 11th December 2014, 8:51 am
Thank you. You saved my day :lol:
0 Larry C Thursday, 3rd April 2014, 1:17 pm
The fix works great, but the problem is occurring a couple of times a day.

Any idea how to fix permantely?
+1 Hans12 Tuesday, 29th October 2013, 1:07 pm
I would hug you if i could! Thank you so much!
+1 abdul p Sunday, 14th April 2013, 2:38 am
Thanks you works perfect!
+1 Mohamad Z Wednesday, 17th October 2012, 10:53 am
It was a nightmare!
Thanks thanks many thanks!
+1 Jorge T Friday, 10th August 2012, 4:10 am
:D :lol: :-) Thank you very much, you saved me!
0 Igor Thursday, 26th April 2012, 1:55 pm
I had a similar problem. And I resolve this one. I deleted joomfish. I think if no work foreach in k2 it means that k2 in conflict with joomfish.
0 Bhavik S Sunday, 22nd April 2012, 12:50 pm
awesome was not able to figure it out how to solve this i restored it two times from my cpanel but all was waste thn i came across your blog from google and the problem solved with just one line query.. :-)
0 Jose L Thursday, 12th April 2012, 4:11 pm
You are a genius! u save my life! Thanks
+1 Joel L Saturday, 24th December 2011, 7:16 pm
Hi Bryan,

If you can send me a link or screenshot I can check for you but msg_text does not necessarily indicate a problem with your K2 setup. From memory, this is a joomla variable but I'll wait to hear from you before suggesting anything.

Kind Regards,

0 bryan Tuesday, 20th December 2011, 3:38 am
hello, i have the same problem but it is still not fixed
the SQL says msg_text is OK
i can't figure out what wrong?
Please help me~
0 Andrew C Friday, 16th December 2011, 8:27 pm
Masterful!!! One of the best fastest absolute fixes I've ever had to do.
0 Rachel H Tuesday, 13th December 2011, 8:32 pm
You are my hero!!!!!!!
0 abdul Wednesday, 7th December 2011, 4:41 am
You saved many days of work. Many many Thanks a lot.
0 Kelly L Monday, 5th December 2011, 9:13 pm
THANK YOU! You saved my day, and now I have time to work on my son's Science project...due tomorrow. Can you help with that too?

Seriously, I appreciate your time to post the resolution. Bless you!
0 tomoceus Monday, 20th June 2011, 1:00 pm
You saved many days of work for me. Thanks a lot.
+1 TazoChai Tuesday, 31st May 2011, 5:24 am
Thanks for this awesome info here.
0 Nuno Saturday, 19th March 2011, 7:44 pm
Over a 1000 K2 items disappeared after 5 hours installing virtuemart! :cry:
Thanks man, this post saved my site.
God bless you!
0 Emax Saturday, 12th February 2011, 9:27 pm
Thanks man, works perfect!
+1 Joe J Tuesday, 28th December 2010, 8:09 am
Hey, thanks buddy! This saved me a lot of time... Thanks again.

Add comment