Author Archives: bernard

MAMP 2.1.1 Character Set Issues

For those that use the latest MAMP 2.1.1 to develop your Joomla products, you may have noticed strange characters in your text output from the database. Like the strange diamond question mark U+FFFD �.  This is caused by inadvertently using different character sets when communicating between PHP and MySQL. I’m using MAMP 2.1.1, which now uses PHP 5.4.4 and MySQL 5.5.25, with Joomla 2.5.6.

Here is the solution I came up with.

Set PHP 5.4.4 php.ini to utf8.

default_charset = "UTF-8"

Let’s see what MySQL reports:

Bernard:~ Bernard$ /Applications/MAMP/Library/bin/mysqladmin variables|grep latin1
| character_set_client          | latin1
| character_set_connection      | latin1
| character_set_database        | latin1
| character_set_results         | latin1
| character_set_server          | latin1
| collation_connection          | latin1_swedish_ci
| collation_database            | latin1_swedish_ci
| collation_server              | latin1_swedish_ci
Bernard:~ Bernard$

Let’s force all connections to MySQL to be utf8.

Bernard:~ Bernard$ cat /Applications/MAMP/conf/my.cnf
 init-connect='SET NAMES utf8'
 Bernard:~ Bernard$

Restart MAMP 2.1.1.

Let’s see what MySQL reports:

Bernard:~ Bernard$ /Applications/MAMP/Library/bin/mysqladmin variables|grep utf8
| character_set_client           | utf8
| character_set_connection       | utf8
| character_set_database         | utf8
| character_set_results          | utf8
| character_set_server           | utf8
| character_set_system           | utf8
| collation_connection           | utf8_general_ci
| collation_database             | utf8_general_ci
| collation_server               | utf8_general_ci
| init_connect                   | SET NAMES utf8
Bernard:~ Bernard$

Looks real good so far.

setUTF() automatically runs in JDatabaseMySQLi :

mysqli_query($this->connection, "SET NAMES 'utf8'");

So, MySQL and JDatabaseMySQLi are set for utf8 but a dump of the connection shows something different.

In my component (Joomla is configured to use MySQLi):

$db = JFactory::getDbo();
string(6) "latin1"

Um, WTH? What went wrong? PHP 5.4.4, MySQL 5.5.25, and Joomla! 2.5.6 are all set for utf8 not latin1. At this point I have no idea. But, after hours of head scratching, the fix is very simple.

In Joomla! edit the JDatabaseMySQLi file located at:


Add this to line 456 within setUTF() :


Now run our dump again we get:

$db = JFactory::getDbo();
string(4) "utf8"

Final thoughts. This is obviously not a long term solution. As soon as you upgrade to Joomla! 2.5.7, it will overwrite your changes to the library. Hopefully this issue will correct itself in the future.

Happy Coding.

cACL Update 1.3.9 for Joomla! 1.5 Access Control

We’ve released Community ACL 1.3.9. We have added several new additions with the way we handle front-end menus. There is now support for yoo_enterprise. We’ve also turned on preserve-entities in libtidy to not change   into the dreaded ‘?’s. To get the look and feel more consistent in the back-end we’ve removed the sort options for the roles. All the columns now sort alphabetically on the group, role, or function name. The “remove all” button on the functions will now work properly as well.

Bug fix version 1.3.8 corrects an issue where the category drop-downs were being replaced with incorrect information.

1.3.7 of Community ACL fixes an issue that showed up as a result of adding libtidy for front-end joomla menu restrictions.

Bug fix version 1.3.6 addresses an issue where in IE8 will not properly remove all list items by clicking the clear all button.

This will not work in Internet Explorer:
tbody.innerHTML = ”;
It’s a known bug that they (MS) have ignored.

But never fear, replace the innerHTML code with:
while ( tbody.childNodes.length >= 1 ){
tbody.removeChild( tbody.firstChild );

We are committed to continuing the improvement of our products. Please feel free to submit support tickets for any issues you are experiencing.

For more information on Community ACL::

Learn more about cACL

Community ACL

Community ACL has some new exciting features and 9 bug fixes in the last few months!
We have added the support for libtidy. This adds the following features:

  • Quickly add code to restrict menus
  • More accurately removes menus
  • Better support for custom Joomla! templates
  • Cleans up improper HTML to help cross browser support
  • Code is specifically created for each template, so after upgrading cACL you will not loose template support.

libtidy is normally enabled in PHP by default. So little is required to use this extension. There is an on/off toggle button on the main config page that will allow you to turn off this feature if you require broken HTML for your template.


We would like to hear from you about what new features would help your experience with Community ACL for Joomla!

The if() Control Structure

if() gives you a choice between outcomes you choose yourself. This gives you the most flexibility out of your projects.

Out of all the control structures, if() is probably one of the most used and has the most flexible ways of being written. Readability should be taken into account when you decide which way to write it. Using braces is the wisest since it doesn’t leave any room for error in what the author meant to include in the statement. if() statements may be written inside functions / methods, inside and outside most other control structures, procedural PHP, and HTML files.

Continue reading