March 10 2013

PHP is_serialized function

Tagged Under :

php
PHP unserialize function is use to convert an array string to an array.

But if the string not in proper array string it will return Notice error like below:
Notice: unserialize() [function.unserialize]: Error at offset 0 of 6 bytes

The easy way to fix this problem is write a function and call it “is_serialized”, use to check the string before unserialize it.

March 10 2013

Yii row number in CGridView

Tagged Under :

Yii
In Yii CGridView it doesn’t provide absolute row number in all the pages.

The easy way is write the a calculation method inside the column to show the column number.

March 10 2013

Yii rules numerical minimum or maximum display error message

Tagged Under :

Yii
Normally in Yii model rules validation to set the error message like below:
array('username', 'required', 'message'=>'username cannot blank.');

But, numerical validate method is different if you set the ‘min‘ or ‘max‘ inside the rules.

March 02 2013

PHP warning: getdate() [function.getdate]: It is not safe to rely on the system’s timezone settings

Tagged Under :

php
I face a weird problem in PHP. I just upgrade to php 5.3.0 and since the upgrade I’m getting the following warning:
Warning: getdate() [function.getdate]: It is not safe to rely on the system’s timezone settings. You are required to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier.
And date.timezone also added. But the warning still there.

February 03 2013

PHP use curl post xml

Tagged Under :

php
Because I want integrate my web application with one of the famous payment gateway. But they didn’t provide any API and just give the documentation only.

So I write the code myself to communicate the payment gateway server.

February 01 2013

Yii PHPUnit CLI has stopped working

Tagged Under : ,

PHPUnit
Few day ago I install PHPUnit3.7 on my PC. and I follow phpunit.de instruction install on my PC.

So far everything working properly. But when I try run it on Yii, it pop out an alert message “CLI has stopped working”.

January 20 2013

Jquery Array Key Search

Tagged Under : ,

jquery
How to using jQuery search the array key or check for a key exists in an array.

Since JavaScript doesn’t really have associative arrays, then we only write a function to check.

January 20 2013

Jquery Static Array

Tagged Under : ,

jquery
Use a short code to get a value from the database the easy way is using Ajax.

But the short code and value are fixed, we keep it in database is for future reuse it.

So I use another way to get the value. That is an array. use array key find the value.

January 16 2013

Jquery Remove White Spacing

Tagged Under : ,


Use jQuery remove white space to avoid user escape required field.

There is one of the functions from jQuery which help to solve this problem.

January 16 2013

Jquery Find Attribute Name Value of Input

Tagged Under : ,

jquery
Because want use jQuery get the input box value but the input box without the id attribute.

Then need use name attribute to find the input box get the value.