From The Blog

PHP: check whether an AJAX request

if ( !empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' ) {   //if ajax...

Read more
Find and Replace Text in MySQL Database using UPDATE statement

update TABLE_NAME set FIELD_NAME = replace(FIELD_NAME, 'find this string', 'replace found string with this string');

Read more
Wordpress: get featured image for a post

How to get featured image "thumbnail" for a post? $feat_image = wp_get_attachment_url( get_post_thumbnail_id($post->ID) ); echo '$feat_image';

Read more
How to know the mode the browser running with ?

How to know the mode the browser running with ? i.e. Standards Mode, Quirks Mode ...   In Firefox and Opera you can determine if your browser...

Read more
gzip compression using .htaccess

You can compress static files such as image files (.jpg, .png, ....), Flash files (.swf), Style sheets (.css), Javascript (.js) to reduce size of...

Read more
Open new Gmail compose email window

To open new gmail compose email window use this url formation: https://mail.google.com/mail/?view=cm&fs=1&tf=1&su=Newest%20Questions%20...

Read more
PHP: make the cookies work globally on all subdomains

To make cookies work globally on subdomains of a domain: setcookie('CookieName', 'Value', time() + 3600, '/', '.mydomain.com'); Note: remember to...

Read more
CakePHP joining tables

In many cases when we want to formulate complex queries, that need joins between tables, we can still add joins on the fly by adding it to the call...

Read more
CakePHP: change default model for a controller

By default a CakePHP controller uses a model with singularized name, for example a controller with name Students will use by default a model named...

Read more
Ubuntu: How to check installation is either 32 bit or 64 bit

How to check installation is either 32 bit or 64 bit ? you can simply type in terminal: getconf LONG_BIT It should result 32 or 64

Read more
PHP: check string has HTML tags

you may think as the best way to check a string has HTML tags is to check the string after stripping tags: if( strlen($string) != strlen(strip_tags...

Read more
CakePHP: Custom routes and pagination

In CakePHP it is pretty easy to change the way that users reach to a specific action to another beautiful URL for ex: you may have a page that...

Read more
CakePHP: Get Client's IP Address

in CakePHP 1.x Through the RequestHandler Component: RequestHandlerComponent::getClientIp(); in CakePHP 2.x RequestHandler::getClientIp() is...

Read more
PHP: client's IP address

The IP Address of the client who sent HTTP request is stored in the server variable: $_SERVER['REMOTE_ADDR'];

Read more
PHP: parsing all the XML including CDATA

It is common when writing XML files to put data like HTML and XML in CDATA to avoid mixing between XML tags and content tags but whatever comes...

Read more
PHP: redirect to referrer page

In PHP to redirect to another page you use: header("location: http://www.example.com"); If we wanted to redirect to the referrer page we use like...

Read more
CakePHP max number of fetched row on pagination

By default, the maximum number of fetched rows on pagination is set to 100 rows, whatever number of rows higher than it you assign it to the "limit...

Read more
CakePHP and MySQL tinyint datatype

I observed that CakePHP treats tinyint fields as boolean (true/false) , but after investigation found that: if you set the data type for a field to...

Read more
PHP: Calculate result of a mathematical expression given in a string

How to calculate the result of a mathematical expression given as a string: function calc_string( $mathString ) { $cf_DoCalc = create_function("", "...

Read more
PHP: Check if cURL is loaded or not

To check client URL (cURL) is enabled or not you can simply: if (in_array ('curl', get_loaded_extensions())) { return true; } else{ return false; }

Read more
Javascript: Easily calculate difference between two dates in days

Date.daysBetween = function( date1, date2 ) { //Get 1 day in milliseconds var one_day=1000*60*60*24; // Convert both dates to milliseconds...

Read more
jQuery: reload an iFrame

//reload 1 iframe $('#iframe').contentWindow.location.reload(true); //reload all iFrames $('iframe').each(function() {   this.contentWindow....

Read more
CakePHP: Multilingual application using URL routes

Here is a simple tutorial on how to develop a multilingual cakephp application through URLs, After having as desired number of language translation...

Read more
Javascript parsing issue on IE7

I had a problem in a page that gets it's content via an ajax request and place the result of the ajax request in a slider, I was testing it on other...

Read more