PHP / MySQL

User login

Remove non-utf8 characters from string

Here is a nice little PHP snippet that will remove non-ASCII characters from a String.

Drupal - Load user's Content Profile, given the UID

There are so many reasons to use Content Profile instead of the user's core profile. For once, profiles are created as separate nodes and therefore the full flexibility of CCK and VIews come in the game. This way it is possible to build some really sophisticated profiles, which is usually what is needed for any website.

I had to look around for an easy solution on how to load the user's content profile programmatically, so the following might come in helpful.

preg_match date time validation

While developing a custom module, I needed to validate the following date time format:

1987-11-22T23:52:12

The following code was used to create a pattern for the preg_match and to test the results. (Can be used as is.)

How to install APC & Uploadprogress on Centos 5

First things first, we need the pecl command in order to download and install APC from the repositories.

Let's run the following command in our terminal:

yum install php-pear

Then, we are making availlable a required package for the phpize command:

yum install php-devel

The followng package will allow apxs command:

yum install httpd-devel

Once we have all the above pakages installed, we are ready to install apc by running the pecl command:

pecl install apc

How to install APC PHP accelerator

Here is a list of commands to install APC php accelerator on CentOS:

yum install php-pear
yum install pcre-devel
yum install php-devel
yum install httpd-devel
pecl install apc-beta
echo "extension=apc.so" > /etc/php.d/apc.ini
service httpd restart

To see if APC is loading, create a php file e.g. info.php with the code phpinfo();.
Search for the APC section in the output of this file.

Subscribe to PHP / MySQL