Saturday, July 5, 2014

MySQL: How to find tables that are using a certain column name?

This SQL helps you list the tables with a certain column name. As you can see in the script, you can also use comma-separated multiple column names.

    SELECT DISTINCT TABLE_NAME 
    FROM INFORMATION_SCHEMA.COLUMNS
    WHERE COLUMN_NAME IN ('column_name1', 'column_name2')
    AND TABLE_SCHEMA='database_name'

You may also use "COLUMN_NAME LIKE" to find a closer match of something you are looking for such as:

    SELECT DISTINCT TABLE_NAME 
    FROM INFORMATION_SCHEMA.COLUMNS
    WHERE COLUMN_NAME LIKE 'column_name%'
    AND TABLE_SCHEMA='database_name'

Sunday, June 29, 2014

"421 service not available closing channel" error

I was trying to send emails to my localhost account in Windows Live Mail and it's giving me an error message "421 service not available closing channel". This is nothing to do with the email client. This is an issue in xampp's MercuryMail folder.

I am using XAMPP 1.8.3 and it appears MercuryMail seems to have "QUEUE" folder missing.

Place a "QUEUE" folder inside MercuryMail as in "C:\xampp1.8.3\MercuryMail\QUEUE" and this problem goes away. The same path for the QUEUE folder should be used in the "Mail queue" tab in Mercury's Configuration > Mercury Core Module Configuration.

Friday, June 20, 2014

Case sensitive table names in MySQL

In Windows, MySQL database tables are saved with lowercase letters. When you import tables with case sensitive names, these get converted into lowercase names. If you want to maintain case sensitivity in MySQL database, do the following:
  • In your MySQL installation folder, find my.ini file and open it. If you are using xampp, it's usually located in /mysql/bin/ directory.
  • In [mysqld] section, modify the value of lower_case_table_names to 0. If this entry is not there already, simply add this line:
    lower_case_table_names = 0
  • Then restart your MySQL server.

Tuesday, March 25, 2014

How to make jQuery Cycle2 plugin compatible with old Cycle plugin?

Malsup's Cycle2 plugin does not work with old Cycle plugin if both of them are used on the same page. It's because both these plugins use the same cycle() method name.

In order to make both of them work on the same page, one of the plugin's cycle() method must be renamed. I tried this with Cycle 2 version 2.1.2 minified production js file and it seems to work fine. If you are using non-minified file, I think the steps will be pretty similar. Follow the steps below.
  • Open up jquery.cycle2.min.js file and replace all "fn.cycle" with "fn.cycle2" and ".cycle(" with ".cycle2(". You don't need to change the class names, etc.
  • If you are initialising the slideshow by invoking the cycle() method in your view or anywhere else, you will need to change the function call too, such as "$('.myslideshow').cycle2()".
  • If you are using additional plugin files of Cycle2, perform find and replace as shown above on each of the files.
That should do it. Let me know if this works for you.

Sunday, February 16, 2014

Deprecated: mysql_connect() error in Opencart 1.5.6.1

In my new xampp 1.8.3 installation, I installed Opencart 1.5.6.1 and received a deprecated warning message such as:
Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in ....\system\database\mysql.php on line 6

The quick way to resolve this issue is by making a small change to the config.php and admin/config.php files. In both these config.php files, look for the line
define('DB_DRIVER', 'mysql');

Modify the above line to
define('DB_DRIVER', 'mysqli');

The new line will simply connect to the database from system/database/mysqli.php file.

Monday, February 10, 2014

PHPBB3 Error: Could not get style data

I moved PHPBB3 files and database from my windows localhost to Linux based remote server. After changing the settings in the remote server's config.php files, I got an error Could not get style data when trying to get to the forum.

The reason for this error was that cache subdirectory was not writeable. Just chmod 777 cache and you should be fine.

Wednesday, January 15, 2014

Joomla: How to add module position within the module or component layout template?

In your site template, you can use something like this to load modules in certain positions:
<jdoc:include name="position-0" type="modules" />
You can't use the above markup within the module or component layout template (we are talking about the php files inside /tmpl subdirectory of your module or component's view). But there is a workaround.

Method 1:
This is a straight Joomla code. You can use the following code to load modules within the module or component layout templates:
<?php 
  $document = &JFactory::getDocument();
  $renderer = $document->loadRenderer('modules');
  $position = 'position-0';
  $options  = array('style' => 'raw');
  echo $renderer->render($position, $options, null);
?>
This will load the modules that are assigned in "position-0" position.

Method 2:
There is another method using an extension if you don't want to write all those lines of code. You can install an extension called Modules Anywhere. Then in your module or component templates, you can use something like this:
{modulepos position-0}
I prefer Method 1 as I don't want to rely on extensions as much as I can but it's your choice.