Joomla: “Error loading Modules”

I’ve been playing with the generic and useless message generated by Joomla 1.5.8 : “Error loading Modules
This problem appeared while using Jumi, a Joomla plugin enabling custom scripts and file inclusion into articles, to include a php script which performs several sql queries.
I used Joomla + Jumi for a long time, without any problem. Now that I’ve moved from a Godaddy Shared Hosting to a Godaddy Virtual Dedicated Server, this problem has appeared.
What the hell was causing that weird message? And why no modules were showing in my page?
After wasting lot of time googling, I realized something with the MySql connection wasn’t fine.
I tried modifying all settings in my.cnf with no luck, I rewrote the script, I reinstalled Jumi… Nothing!
Before giving up, I looked into the php.net manuals.
HEY, FOUND THE PROBLEM!
Mysql has a “weird” behaviour: if you open 100 connections to 100 different databases in the same server, MySql uses the same connection id for each connection!
So if you do
$db1 = mysql_connect($host, $user, $pass);
$db2 = mysql_connect($host, $user, $pass);
mysql_select_db(‘db1′, $db1);
mysql_select_db(‘db2′, $db2);
you get a race condition: only db2 is selected.
That’s why my modules didn’t show !

What to do?
My workaround to fix the “multiple connections problem” with MySql is the following:
$host1 = “localhost”;
$host2 = “127.0.0.1″;
$host3 = “127.0.0.1:3306″;
$host4 = “localhost:3306″;
$db1 = mysql_connect($host1, $user, $pass);
$db2 = mysql_connect($host2, $user, $pass);
$db3 = mysql_connect($host3, $user, $pass);
$db4 = mysql_connect($host4, $user, $pass);

Hope it helps!
Any comment is welcome!

References:

http://www.matteogiannone.com/blog/2009/11/joomla-1-5-error-loading-modules/ (Italian)

Tags: , , , ,

35 Responses to “Joomla: “Error loading Modules””

  1. Daniel Allen Says:

    Thank you! Thank you! Thank you! Thank you! Thank you! Thank you! Thank you! Thank you! Thank you! Thank you! Thank you! Thank you! Thank you! Thank you! Thank you! Thank you! Thank you! Thank you!
    OMG! You just saved me so much time and I thought I was going crazy!! I installed jumi and had the same problem and it only happened on the script calling another database. Everything worked great calling the php file directly, but through jumi it was kinda working. So I thought it was joomla and you had to connect to databases in a very specific way and I wasn’t getting anywhere with that. So I googled: “Error loading Modules:” jumi
    And this page came up and you became my hero! I don’t know how you figured this out, but I would never have figured this out in a million years! Even if I had read the php.net manuals! So for me I used “localhost:3306″ and everything was working again! So thank you very much for A) figuring this out and B) for sharing the solution with the world.

  2. admin Says:

    Nice to see someone finding this post useful :)

  3. Mohammed Says:

    Thanks you very much for the solution and the fact you share it…..I have the same problem and i tried a lot of ways without result…Now it’s OK Thanks you

  4. Sharif Says:

    Thank you soo mery much. I was pulling out my hair on this one.

  5. KattyBlackyard Says:

    Hi, very nice post. I have been wonder’n bout this issue,so thanks for posting

  6. I AM Says:

    THANK YOU GOD!

  7. Scitek Says:

    Really… this is very useful, I spend a lot of time trying ways to solve this problem, so… u r the man!

  8. QuickLearner Says:

    Awesome stuff. Was breaking my head over it for half a day atleast :)

  9. Satish babu Says:

    Thanks Buddy saved my time

  10. DFUSED Says:

    holy smokes…. I’m yet another user that was battling this till I found your page. Then went DOH!…
    Thanks so much. You ought to post some entries into reply to bump ranking in search engines.

  11. jglass Says:

    just wanted to add my thanks – this was driving me crazy!

  12. pholcomb Says:

    To follow everyone else’s words, “I think I love you”. Ha. I racked my brain for hours trying to figure this out. Thanks for the post.

  13. Buckwheatpie Says:

    Hi, this is very helpful cos i’m having a similar problem – perhaps you can help? or anyone else reading this?

    i have only called one DB connection, yet am still getting 17 “Error Loading Module” errors!

    i’m a beginner, and i’m trying to use Jumi to bring a table of the titles of all the articles in a certain category to appear at the bottom of an article – my code (with HTML table bits stripped out for convenience) is:

    [code]

    [/code]

    The list of articles in category 53 does appear underneath all the “Error loading module” messages…

    any ideas? many thanks!

  14. CMK Says:

    why didn’t I Google sooner….thanks :-)

  15. Rowena Says:

    Oh thankyou so much. You are a guru. :o )

  16. Brian Says:

    Very nice and much appreciated. Another reason why open source is so great; the people who use it are so generous.

  17. seraphim Says:

    Thank you very much. It worked immediately and saved a lot of time.

  18. Javier Says:

    thanks a lot man, for sharing this information.. Saved a lot of hours of research and headache… Thanks again!!

  19. James Cagney Says:

    Same as everyone else. THANKS guy!! So much help!

  20. mheidzir Says:

    thank you so much, it is really helpful

  21. Liviu Says:

    I have also used your trick. Thanks.

  22. muzza Says:

    Thank you.
    great solution !!

  23. ViserExcizer Says:

    omg thanks alot, i keep getting these errors even after turning off error reporting. The problem happens if I try to connect two different databases using the same database login information.

    127.0.0.1 = localhost =lifesaver. Thanks!!

  24. Noel Says:

    thanks a lot , you are the man of the game……..
    So clever like you i would like to be in my dreams:)
    Thanks again it was very, very helpful.

  25. Alysson Franklin Says:

    amazing, that was fast!

    thanks m8! you saved my dawn!

  26. MoniManu Says:

    @Buckwheatpie: hello. Did you find an answer to your problem? Because I have the same one.

  27. LA Says:

    $host1 = “localhost”;
    $host2 = “127.0.0.1″;
    $host3 = “127.0.0.1:3306″;
    $host4 = “localhost:3306″;
    $db1 = mysql_connect($host1, $user, $pass);
    $db2 = mysql_connect($host2, $user, $pass);
    $db3 = mysql_connect($host3, $user, $pass);
    $db4 = mysql_connect($host4, $user, $pass);

    where will i put this?

  28. Siddharth Says:

    Wow man.. You’re my hero too!! I had no clue how to make it work! You’re a genius!!

  29. Mendy Says:

    Thanks a million~!!!!!!!!!!!!!!!!!!!!!!!!

  30. bomajo Says:

    Big help. Thanks for taking the time to write the solution.

  31. melaparto Says:

    Yeah, yeah and Yeahhhhh!!!
    Thanks a lot!
    I am using Joomla with myTableEditor and this one was breaking my nerves due to database connections problems… Solved with your help. Many Thanks!!!

  32. Tosh Says:

    I have the same question as LA .. where do you put this code?

    $host1 = “localhost”;
    $host2 = “127.0.0.1″;
    $host3 = “127.0.0.1:3306″;
    $host4 = “localhost:3306″;
    $db1 = mysql_connect($host1, $user, $pass);
    $db2 = mysql_connect($host2, $user, $pass);
    $db3 = mysql_connect($host3, $user, $pass);
    $db4 = mysql_connect($host4, $user, $pass);

  33. admin Says:

    @LA and @Tosh :
    those are alternative ways to open a connection to the mysql server: this code is inside the component/plugin causing problems.

  34. Mike Forrester Says:

    And again Sir, thanks

    If you are ever in Javea, Spain – I owe you several beers.

    Even though I was only connecting once, to populate a content page with a database extract, I was getting several ‘Error…’ messages. The database extract itself would work lovely, but Joomla would not load any page stuff.

    Simply adding :3306 to my mysql_connect(…) hostname solved the problem.

  35. sirTemplar Says:

    THANK YOU very much for sharing this solution. I use phpinclude and had the same problem and spent 2 days before i found your solution. thanks again!

Leave a Reply