Make lowercase followed by uppercase data

Question :

I have table A with field id, name and address. The data in name field seem not consistent, big letter name sometime found in record. How to update that field with uppercase in name field. For example :

                 id              name                                       address

                 1               FreAKHolicz  wORker            the moon

                 2              tHE atMOSFER bluEZ            nowhere

FreAKHolicz  wORker must change to Freakholicz Worker

Answers :

1. Looping

2. Use strtolower() function followed by ucwords() function.

example code :


$query=mysql_query("select id,name from table A");



//change to lower case

$name1=strtolower($name); // will make FreAKHolicz  wORker  into freakholicz worker

//change to uppercase

$name2=ucwords($name1); // will make freakholicz worker into Freakholicz  Worker

//now using $name2 as variable to update name field

$update=mysql_query("update A set name=’$name2′ where id=’$id’");



since it’s looping, all good record also examined by scripts until no record left, using another conditional condition would bring another result.

P.S :

  • Use ucfirst() to change only first alfabet
  • Its possible using many function in one operation such as :  $name2=ucwords(strtolower($name));
in PHP | 339 Words

Export picture from mysql database to file

As our data getting mobile and copying picture is annoying for me I decide to save the picture in the database (mysql).

Another challenge came when other division need the data exported in a directory with same dimension (135 x 180 pixel).

Structure for table ‘student_pic’  :

CREATE TABLE `student_pic` (
  `image_id` int(10) unsigned NOT NULL auto_increment,
  `username` varchar(50) NOT NULL default ”,
  `image_type` varchar(50) NOT NULL default ”,
  `image` longblob NOT NULL,
  `image_size` bigint(20) NOT NULL default ‘0’,
  `image_name` varchar(255) NOT NULL default ”,
  `image_date` datetime NOT NULL default ‘0000-00-00 00:00:00’,
  UNIQUE KEY `image_id` (`image_id`)

Yes, I use mysql 5 ( 5.0.45)

Continue reading

PHP 5.2.5 Released, 7 security enhancements & fixes


The PHP development team would like to announce the immediate availability of PHP 5.2.5. This release focuses on improving the stability of the PHP 5.2.x branch with over 60 bug fixes, several of which are security related. All users of PHP are encouraged to upgrade to this release.

Further details about the PHP 5.2.5 release can be found in the release announcement for 5.2.5, the full list of changes is available in the ChangeLog for PHP 5.

Security Enhancements and Fixes in PHP 5.2.5:

  • Fixed dl() to only accept filenames. Reported by Laurent Gaffie.
  • Fixed dl() to limit argument size to MAXPATHLEN (CVE-2007-4887). Reported by Laurent Gaffie.
  • Fixed htmlentities/htmlspecialchars not to accept partial multibyte sequences. Reported by Rasmus Lerdorf
  • Fixed possible triggering of buffer overflows inside glibc implementations of the fnmatch(), setlocale() and glob() functions. Reported by Laurent Gaffie.
  • Fixed "mail.force_extra_parameters" php.ini directive not to be modifiable in .htaccess due to the security implications. Reported by SecurityReason.
  • Fixed bug #42869 (automatic session id insertion adds sessions id to non-local forms).
  • Fixed bug #41561 (Values set with php_admin_* in httpd.conf can be overwritten with ini_set()).

For users upgrading to PHP 5.2 from PHP 5.0 and PHP 5.1, an upgrade guide is available here, detailing the changes between those releases and PHP 5.2.5.

Download now.

in PHP | 215 Words

Create Paging with PHP : Link collection

Soon or later everyone who learn php will face this thing : ‘paging

blog, guest book, search result are using paging for displaying data. Make it easy to read and more friendly

some picture of paging implementation :

 php paging

php paging

php paging

 Good paging code will survive when record in database or file system getting bigger.

many url in internet exist for such purpose, teach how to create paging with php.

I start to collect them in this page that might be useful for someone who like to implement paging in his guestbook, search result etc.

Some urls : 


Maybe you have found useful url that might help others?

I’ll update the list if I have other link.

Tell me please 🙂

in PHP | 170 Words

Multiple domains login in roundcube webmail

Roundcube is very good solution for webmail. I use squirrelmail for almost 4 years and I like it too.

In production server I install squirrelmail and roundcube as well for give other user different experience 🙂

using mail and mail2 as prefix and multiple domains need special attention in roundcube.

After search in their forum I like this snippet :

 function getDomain() {




    if ($arr[0]==$prefix) { unset($arr[0]); $host=implode(‘.’,$arr); }

    else { $host=”; }

    return $host;


plus this line :

$rcmail_config[‘username_domain’] = getDomain();

 put that in config/

for my case where I use mail and mail2 just edit the line :

if ($arr[0]==$prefix) { unset($arr[0]); $host=implode(‘.’,$arr); }


if ($arr[0]==$prefix or $arr[0]==’mail2′) {

unset($arr[0]); $host=implode(‘.’,$arr);


 Working  well for me 🙂