Category Archives: PHP

Install PHP DB2 libraries on CentOS

We came across the requirement to manipulate DB2 using PHP scripts. In order to be able to do that you need to the DB2 libraries installed on your machine. First of all install DB2 Express ( desired version, we used 11.1 ). Make sure you are installing the development libraries with the product as you will need this when you compile the DB2 PHP libraries. Once the server is installed check out the content of the following directory /home/db2inst1/sqllib/include/ if you see a bunch of files in there you have the development pack installed and you are good to go. if you used a different instance name obviously check in there 🙂

The following command sequence will get the rest sorted, we assume you already have php installed on your machine.

  • yum install php-pear
  • yum install php-devel
  • yum install gcc
  • pecl install ibm_db2

The installer will ask where the DB2 directories are located,  just define the directory of your instance. Since we have db2inst1 as the instance the DB2 directory is located at /home/db2inst1/sqllib.

The installer will now compile the PHP libraries. Once it is done just add into your php.ini file and you are good to go.

Adding a MySQL Data Source to TEPS using JDBC

We had a requirement to display data from a remote MySQL database on TEPS. There is absolutely no documentation on how to do this so I attempt to explain how we managed to sort this out.

1: Check if you can get to the MySQL database from the TEPS server. You can run the following PHP script if it is not giving an error the connection is working fine! Replace
the highlighted variables with your own details.


// opening DB connection

$dbhost = ‘database_hostname‘;
$dbuser = ‘database_username‘;
$dbpass = ‘database_password‘;

$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die (‘Error connecting to mysql’);

$dbname = ‘database_name‘;


2: Add the MySQL data source to the TEPS datasource list. We used the following command:

/opt/IBM/ITM/bin/tacmd configurePortalServer -s DSUSER2 -p UID=database_user PWD=database_password CONNECTION_TYPE=JDBC KFWJDBCDRIVER=com.mysql.jdbc.Driver KFWDSURL=jdbc:mysql://database_hostname:3306/database_name

This will create the DSUSER2 datasource.

3: Download MySQL JDBC connection driver from

4: Add MySQL JDBC connection driver to cq.ini this will ensure that the driver is loaded.


5: Restart TEPS

Once teps is restarted the new data source should show up when you try to create a custom query on TEPS. Simply enter the SQL you would like to run against the MySQL database and the data should show up on teps in table format.

Matrice – Prestashop 1.4.3 – Undefined variable: nb_products FIX

I am rebuilding one of our webshops and run into this nasty error when clicking on the home category from the TOP navigation menu.

Notice: Undefined variable: nb_products in /var/www/html/shopname/tools/smarty/sysplugins/smarty_internal_data.php on line 291 There are no products.

We are using the Matrice theme which is truly amazing however there seems to be an issue here with it. If you run into the same as a quick fix just change the following in the category.tpl:


{if $nb_products == 0}{l s=’There are no products.’}


{if $nb_products == 1}{l s=’There is’}{else}{l s=’There are’}{/if}&#160;
{if $nb_products == 1}{l s=’product.’}{else}{l s=’products.’}{/if}





{if $nb_products == 0}{l s=’There are no products.’}



{if $nb_products == 1}{l s=’There is’}{else}{l s=’There are’}{/if}&#160;
{if $nb_products == 1}{l s=’product.’}{else}{l s=’products.’}{/if}



Make sure that you are changing the Matrice theme not the default one 🙂

Handling Hungarian character set from PHP – Ő Ű problem

I have started to write an app in php and run into the good old character set problem.Ő and Ű characters were not displayed correctly however I have converted the data back and forth. The key is to use UTF-8 encoding.

You have to tell php what encoding to use you can achieve this either using the HTML or the PHP definition. Whichever suits you. Add this to the header section of the HTML code:

<meta http-equiv=”content-type” content=”text/html; charset=UTF-8″ >

You can achieve the same using the header php command:

header(“Content-Type: text/html; charset=utf-8”);

Now we have to make sure that the data coming from the mysql database is UTF-8 encoded. Add this right after the database connection line.

$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die (‘Error connecting to mysql’); // Add UTF-8 converting after this line
mysql_query(“SET NAMES UTF8”);

Make sure that the php file itself is saved from the editor in UTF-8 format. Each progamming editor has the capability to change the character encoding.

Finally check your database if  the tables and the database are utf8_hungarian_ci encoded. MySQL connection collation should be set to utf8_general_ci.

That should be it 🙂