Tag Archives: Postaday2011

WordPress – Enable PHP Session

Add the following code under the top PHP opening tag of wp-config.php.

<?php
  if (!session_id()) {
    session_start();
  }
...

We can now make use of the $_SESSION[] in WordPress. The reason of putting the session_start() in wp-config.php is because this configuration file will not be overwritten during a WordPress update.

Thanks Frank Verhoeven.

Done =)

Reference: Frank Verhoeven – Using Sessions in WordPress

Updated @ 2012-08-02: Please note that their maybe security issue of using the PHP session. For more information, please refer to the following link.
PHP $_SESSION variables

MySQL – Data Type Conversion

Sometimes we need to convert the selected data into other content type. Here is an example.

Assume we got a table with a VARCHAR column which stores number only.

mysql> SELECT * FROM demo;
+----------+
| a_string |
+----------+
| 1        |
| 2        |
| 3        |
| 4        |
| 5        |
| 6        |
| 7        |
| 8        |
| 9        |
| 10       |
| 11       |
| 12       |
| 13       |
+----------+
13 rows in set (0.00 sec)

Continue reading MySQL – Data Type Conversion

Drupal – Fix Ubercart Error Messages

If you get a bunch of error messages after installing Ubercart as follow

  • # Notice: Undefined index: #element_validate in summarize_form() (line 27 of /var/www/pressflow-6.20/sites/all/modules/ubercart/uc_store/includes/summaries.inc).
  • # Notice: Undefined index: #type in summarize_element() (line 84 of /var/www/pressflow-6.20/sites/all/modules/ubercart/uc_store/includes/summaries.inc).
  • # Notice: Undefined index: #type in summarize_element() (line 124 of /var/www/pressflow-6.20/sites/all/modules/ubercart/uc_store/includes/summaries.inc).

No worry, these messages could be removed after modifying the error reporting setting in the php.ini. Continue reading Drupal – Fix Ubercart Error Messages

子華文集 – 棟篤屁 之 港人游港

棟篤屁之港人游港

政府常有宣傳片,呼籲市民舉止有禮,對外國人尤其要含情脈脈,面上多掛笑容,用微笑來催谷旅遊。
  
我每次看到這些短片,都會立刻大受感染,當場嘴角掀動,微微嘴笑以至最後忍不住哈哈大笑。
  
人人笑一笑,香港的旅遊事業會更加光明,我相信。
  
有人會為了香港的整體利益,每天提醒自己要面帶笑容,哈哈哈哈哈哈哈,對不起,我又太過感動了。
  
大佬,共產主義還未降臨呢! Continue reading 子華文集 – 棟篤屁 之 港人游港

Drupal – Customized the User Registration Form

For the Drupal registration form, there is no .tpl.php template file for editing the registration form layout. So if you want to add more HTML code around the form, you have to do it on code level.

I found a useful post about modifying the registration form. It make use of the template.php in the theme folder to theme the form. For more information. Please visit Drupal – Custom registration page theme.

In this post, i will modify the registration form by creating a custom module. Continue reading Drupal – Customized the User Registration Form

Configure Postfix/Sendmail for PHP mail() in Ubuntu

Actually configure Postfix or Sendmail for PHP mail() is the same. Both of them run the /usr/sbin/sendmail binary. It is quite confusing if we just look at the name of the binary but this is what Postfix did.

For more information, take a look at the Postfix Manual – sendmail.

For the PHP setting, open the /etc/php5/apache2/php.ini and configure the sendmail_path. Continue reading Configure Postfix/Sendmail for PHP mail() in Ubuntu

Postfix – Relay via Gmail

Setting up Sendmail to relay public SMTP server such as Gmail is quite difficult. In the past, i just kept looking for the blog posts in Google and found that people have different ways to setup Sendmail, but not all of them could be repeated successfully in my setup. After so many trials and errors, i made the relay works but i couldn’t fully understand what’s going on in the setup.

So this time, no more Sendmail, i would like to use Postfix instead. Continue reading Postfix – Relay via Gmail