Archive for the ‘Mysql’ Category

MCrypt - phpmyadmin: cannot load mcrypt extension

Sunday, January 11th, 2009

Using phpmyadmin frontend to manage your database is straightforward. Just put in the address bar of your browser your server ip address followed by /phpMyAdmin (for example: http://192.168.1.1/phpMyAdmin .

Using it on my Godaddy Virtual Dedicated Server (VDS) showed a little warning: “cannot load mcrypt extension”

What is mcrypt?
Mcrypt is an encryption library which supports various algorithms like DES, TripleDES, Blowfish, TWOFISH, 3-WAY, SAFER-SK64, SAFER-SK128, TEA, RC2 and GOST in CBC, OFB, CFB and ECB cipher modes.

How to install mcrypt under Fedora Core 7 ?
Very easy, simply write these commands as root:

yum install libmcrypt
yum install php-mcrypt*
yum install php-mhash*
service httpd restart

Reload your phpMyAdmin page, and the warning won’t show again.

Joomla: “Error loading Modules”

Monday, December 15th, 2008

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!