PHP Prepare IN statement from array

April 14, 2014

Some of us may not know that when preparing mysql IN statement, the string inside the IN() need to be single quoted and separated by comma. Example: Unless it is a number. Otherwise double quote or no quoting the string will give you error. Example: WHERE categories IN (“red”, “blue”, “green”) To prepare IN statement […]

PHP how to destroy session id

April 14, 2014

The unset() function is used to free the specified session variable: or better catch

Javascript how to alert view array or object

April 14, 2014

Easiest way is using .toSource() alert(arrayObj.toSource());

Remove CSS attribute with jQuery

April 14, 2014

Example to remove a style attribute from html code

jQuery get id of last div inside a div

April 8, 2014

The correct way to get the id of the last child div inside parent container using jQuery: Or

PHP check if a string is JSON

April 7, 2014

Simple method will be: This method doesn’t rely on heuristics, uses native php functionality, and is about as future-proof as you’re gonna get; it just tells you straight up whether there were any errors in decoding the string.

Ubuntu check PHP and mysql version

April 7, 2014

From command line: php -v mysql -V or php -i | grep -i ‘^libxml’

PHP html entity decode UTF-8 encoding

April 7, 2014

For a multilanguage site, using html_entity_decode without encoding type is risky to your website as in some cases, the translated language show weird characters. In version of php prior to 5.4.0, if encoding omitted, default encoding value is ISO-8859-1, and UTF-8 auto set only from PHP 5.4.0 Constant Name Description ENT_COMPAT Will convert double-quotes and […]

PHP obtaining the next month, date-string parser

March 26, 2014

The correct way of obtaining next month correctly is by using “first day of next month” or using “last day of next month”. In normal case, user next month in php to obtain next month value doesn’t work as expected, but it skips to month after next month, Example: Output will be: March. Which suppose […]

jQuery check if element exist

March 17, 2014

To check the length of the selector, if it returns you something then the element exists else not exist. Use: