K2 Items disappear

K2 Items disappear

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:

copyraw
Warning: Invalid argument supplied for foreach() in /home/public_html/administrator/components/com_k2/views/items/tmpl/default.php on line 80
  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:

 

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

Warning: Invalid argument supplied for foreach() in /home/public_html/administrator/components/com_k2/views/comments/tmpl/default.php on line 145
  1.  Warning: Invalid argument supplied for foreach() in /home/public_html/administrator/components/com_k2/views/items/tmpl/default.php on line 80 
  2.   
  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:
 
copyraw
#145 - Table './jos_k2_items' is marked as crashed and should be repaired
  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:
copyraw
REPAIR TABLE jos_k2_items
  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").

Category: Joomla :: Article: 277

Comments

Not rated
newseason
0
newseason
10 years ago
Thank you. You saved my day :lol:
Like Like
Reply | Reply with quote | Quote
Larry Coonrod
0
Larry Coonrod
11 years ago
The fix works great, but the problem is occurring a couple of times a day.

Any idea how to fix permantely?
Like Like
Reply | Reply with quote | Quote
Hans12
1
Hans12
12 years ago
I would hug you if i could! Thank you so much!
Like Like
Reply | Reply with quote | Quote
abdul paksc
1
abdul paksc
12 years ago
Thanks you works perfect!
Like Like
Reply | Reply with quote | Quote
Mohamad Zahedi
1
Mohamad Zahedi
13 years ago
It was a nightmare!
Thanks thanks many thanks!
Bests
Like Like
Reply | Reply with quote | Quote
Jorge Torres
1
Jorge Torres
13 years ago
:D :lol: :-) Thank you very much, you saved me!
Like Like
Reply | Reply with quote | Quote
Bhavik Shah
0
Bhavik Shah
13 years ago
awesome bussy....it 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.. :-)
Like Like
Reply | Reply with quote | Quote
Jose Luis
0
Jose Luis
13 years ago
You are a genius! u save my life! Thanks
Like Like
Reply | Reply with quote | Quote
bryan
0
bryan
13 years ago
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~
Like Like
Reply | Reply with quote | Quote
View replies
WebmasterLegacy
1
WebmasterLegacy
13 years ago
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,

Joe
Like Like
Reply | Reply with quote | Quote
Andrew Crossan
0
Andrew Crossan
13 years ago
Masterful!!! One of the best fastest absolute fixes I've ever had to do.
Like Like
Reply | Reply with quote | Quote
Rachel Hart
0
Rachel Hart
13 years ago
You are my hero!!!!!!!
Like Like
Reply | Reply with quote | Quote
abdul
0
abdul
13 years ago
You saved many days of work. Many many Thanks a lot.
Like Like
Reply | Reply with quote | Quote
Kelly Langston
0
Kelly Langston
13 years ago
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!
Like Like
Reply | Reply with quote | Quote
tomoceus
0
tomoceus
14 years ago
You saved many days of work for me. Thanks a lot.
Like Like
Reply | Reply with quote | Quote
TazoChai
1
TazoChai
14 years ago
Thanks for this awesome info here.
Like Like
Reply | Reply with quote | Quote
Nuno
0
Nuno
14 years ago
Over a 1000 K2 items disappeared after 5 hours installing virtuemart! :cry:
Thanks man, this post saved my site.
God bless you!
Like Like
Reply | Reply with quote | Quote
Emax
0
Emax
14 years ago
Thanks man, works perfect!
Like Like
Reply | Reply with quote | Quote
Joe Johnson
1
Joe Johnson
14 years ago
Hey, thanks buddy! This saved me a lot of time... Thanks again.
Like Like
Reply | Reply with quote | Quote
Viktor
0
Viktor
15 years ago
Thanks. Your solution run 100% perfect, I probe the sql sentence and "voila" all structure table and items were restore.

Thaks again.
Like Like
Reply | Reply with quote | Quote
anon e guy
2
anon e guy
15 years ago
Thank you, sir! Regular "repair table" command wasn't available due to the table being crashed - your fix saved my day (week, month?)
Like Like
Reply | Reply with quote | Quote
george
0
george
15 years ago
Thanks man u saved me from hell it worked perfect like magic
Like Like
Reply | Reply with quote | Quote
Joey
1
Joey
15 years ago
you my friend are LIFE SAVER.. Question, I am an artist and dabble in developing so fixes like these are truly worth there weight in gold. But why did this occur? It happened just like you stated, I made some updates last night and this morning, POOF they were all gone! First time this has happened, just trying to understand the why. Again, thanks a bunch
Like Like
Reply | Reply with quote | Quote
View replies
WebmasterLegacy
0
WebmasterLegacy
15 years ago
Hi Joey,

I recreated this error by overloading a Joomla! CMS website with extensions that I've installed and uninstalled. Basically a lot of third party extensions (especially modules) do not have uninstall scripts, so my database had more tables that were no longer used than ones I was actually using.

I think basically, it's too much for your server to handle in terms of having to read a huge database file so housekeeping is key.

I thought I didn't have much installed when it happened to my site; but both my K2 and Remository (=download manager extension) had crashed. And that was only with about 100 downloads of a Joomla! module I had written. Everything that you install will each send several queries to your servers and the database, too many in fact.

Overloading the server was my issue. This isn't saying that this is what caused your error or that K2 are excess code. All I can do is say what happened to me and what fixed it. There are reports that it keeps happening to people but I'm lucky so far.

Glad this got your K2 articles back :c) Happy to help.
Like Like
Reply | Reply with quote | Quote

Add comment

Your rating:

Submit

Credit where Credit is Due:


Feel free to copy, redistribute and share this information. All that we ask is that you attribute credit and possibly even a link back to this website as it really helps in our search engine rankings.

Disclaimer: Please note that the information provided on this website is intended for informational purposes only and does not represent a warranty. The opinions expressed are those of the author only. We recommend testing any solutions in a development environment before implementing them in production. The articles are based on our good faith efforts and were current at the time of writing, reflecting our practical experience in a commercial setting.

Thank you for visiting and, as always, we hope this website was of some use to you!

Kind Regards,

Joel Lipman
www.joellipman.com

Accreditation

Badge - Zoho Creator Certified Developer Associate
Badge - Zoho Deluge Certified Developer
Badge - Certified Zoho CRM Developer

Donate & Support

If you like my content, and would like to support this sharing site, feel free to donate using a method below:

Paypal:
Donate to Joel Lipman via PayPal

Bitcoin:
Donate to Joel Lipman with Bitcoin bc1qf6elrdxc968h0k673l2djc9wrpazhqtxw8qqp4

Ethereum:
Donate to Joel Lipman with Ethereum 0xb038962F3809b425D661EF5D22294Cf45E02FebF

Please publish modules in offcanvas position.