How to run mysql query without cache?

Following query would be demonstrate how to run a MySQL query without Cache enable.

SELECT SQL_NO_CACHE id, name FROM customer;

Keep Querying 🙂


Redirect request to other domain

I was trying to redirect all of my one wordpress blog setup which is setup on sub directory to the dedicated wordpress domain. To do so I have added following in directory based blog’s htaccess file:

RewriteEngine on

RewriteCond %{HTTP_HOST} ^$ [NC]
RewriteCond %{REQUEST_URI} ^/wp-blog/(.*) [NC]
RewriteRule ^(.*)$

RewriteCond %{HTTP_HOST} ^$ [NC]
RewriteCond %{REQUEST_URI} ^/wp-blog/(.*) [NC]
RewriteRule ^(.*)$

મારિ મા

કેમ કરિને ભુલાય તારો પ્રેમ મારિ મા!
આજે મને પન મને દેખાય છે અશ્રુઓ ના બિન્દુ તારિ આખો ના કિનારે જયારે કોઇ મને દુખ દે છે.

કેમ કરિને ભુલાય તારિ હુમ્ફ મારિ મા!
આજે પન મને યાદ આવે છે તારિ સાડિ નો પાલવ મારી ગમ્ગિન મા.

કેમ કરિને ભુલાય તારો સહારો મારિ મા!
આજે મને પન મને જરુર છે તારો ખભો(ટેકો) આ સ્વાર્થિ દુનિયા મા.

Types of fulltext search functions

I do remember my old days when I am new to MySQL and Web industry. At that point of time whenever I have to implement search functionality I was used to implement it via LIKE keyword as below:

SELECT * FROM tbl_name WHERE col_name LIKE “%search_term%”

At that time I am not aware of full-text search. When I explore through Full-Text search I laugh at myself just because of silly stuff I was doing. I found Full-Text search is much powerful, efficient, faster and accurate way to present results of search query.

To perform Full-Text search you need to define indexing on required columns.

There are few constrain to use Full-Text search:

  1. Full-Text index can be used by MyISAM storage engine only
  2. Full-Text index can be defined on CHAR, VARCHAR and TEXT datatype only.
  3. Full-Text index is an index type of FULLTEXT

Basic syntax of  full-text search function is:

MATCH(col1, col2, col3, ….) AGAINST (search_expr [search_modifier])

in above, MATCH takes comma separated column’s name and AGAINT takes string to be searched.

There are three different types of full-text searches available in MySQL

  1. Boolean Search
  2. Natural Language Search
  3. Query Expansion Search

Pages: 1 2

session lost between http and https

Today I came across strange problem. Let me explain you exact problem and solution for that.


I have e-commerce site developed. After product added to shopping cart when user trying to checkout I am redirecting user from Shopping cart to Account page (if user already logged in) or Login Page (if user not logged in) on checkout. To make transaction more secure, Transition from shopping cart to Account page or Login Page is HTTP (Non-Secure) to HTTPS (Secure). Whenever I switch from HTTP to HTTPS, My stored shopping cart items which are stored in $_SESSION variable get lost.


After much hair pooling to trace and fix this issue I have found below solution:

When you switch between the HTTP and HTTPS services on the same server, your HTTP session ID is not being passed to the HTTPS session. Here we need to pass session_id which is created by HTTP to HTTPS page. so HTTPS resume similar session on server rather then creating new session for HTTPS request. Below is the code to explain it via example:

Consider you are redirecting to

page1.php script:

$sess_id = session_id();
$_SESSION[‘someVar’] = “Var Value”;
echo “<a href=’'&#8221;.$sess_id.”>Page2</a>”;

page2.php script:

if(isset($_GET[‘sess_id’]) && $_GET[‘sess_id’]!=””)

Hope above given solution help others as well.

Post comments if you have any question.

Happy Coding. 🙂

Error Levels in PHP

Following error levels constants available into PHP for error_reporting which are configured directly from php.ini, .htaccess or directly from php script using ini_set function:

Value Constant Description
1 E_ERROR Fatal run-time errors. These indicate errors that can not be recovered from, such as a memory allocation problem. Execution of the script is halted.
2 E_WARNING Run-time warnings (non-fatal errors). Execution of the script is not halted.
4 E_PARSE Compile-time parse errors. Parse errors should only be generated by the parser.
8 E_NOTICE Run-time notices. Indicate that the script encountered something that could indicate an error, but could also happen in the normal course of running a script.
16 E_CORE_ERROR Fatal errors that occur during PHP’s initial startup. This is like an E_ERROR, except it is generated by the core of PHP.
32 E_CORE_WARNING Warnings (non-fatal errors) that occur during PHP’s initial startup. This is like an E_WARNING, except it is generated by the core of PHP.
64 E_COMPILE_ERROR Fatal compile-time errors. This is like an E_ERROR, except it is generated by the Zend Scripting Engine.
128 E_COMPILE_WARNING Compile-time warnings (non-fatal errors). This is like an E_WARNING, except it is generated by the Zend Scripting Engine.
256 E_USER_ERROR User-generated error message. This is like an
E_ERROR, except it is generated in PHP code by
using the PHP function trigger_error().
512 E_USER_WARNING User-generated warning message. This is like an E_WARNING, except it is generated in PHP code by using the PHP function trigger_error().
1024 E_USER_NOTICE User-generated notice message. This is like an
E_NOTICE, except it is generated in PHP code by
using the PHP function trigger_error().
2048 E_STRICT Enable to have PHP suggest changes to your code which will ensure the best interoperability and forward compatibility of your code.
4096 E_RECOVERABLE_ERROR Catchable fatal error. It indicates that a probably dangerous error occured, but did not leave the Engine in an unstable state. If the error is not caught by a user defined handle (see also set_error_handler()), the application aborts as it was an E_ERROR.
8192 E_DEPRECATED Run-time notices. Enable this to receive warnings about code that will not work in future versions.
16384 E_USER_DEPRECATED User-generated warning message. This is like an E_DEPRECATED, except it is generated in PHP code by using the PHP functiontrigger_error().
30719 E_ALL All errors and warnings, as supported, except of level E_STRICT in PHP < 6.

What is error_reporting & display_error?

There are little misunderstanding regarding two good configuration variables  available in php.ini.

  • error_reporting: This enables you to set error level i.e what are the different types of error you would like to log/show. All possible values for this setting are shown here
  • display_error: This enables you to show/hide errors on user browser if any error generated. Value for this setting will be on/off. Generally for development environment this should be on and for production environment this should be off due to security reason.

Both of the above settings are good for debugging and keep your application error free.

Happy Coding!

Post your comments if you have any question.