Sorting the Enum Filed value in Mysql


I’m trying to sort the Enum filed integer  value  with my own level of priority. i try in google and get the lots of result with irrelavent matches and finally i got the solution.

We can sort the enum values by using the ORDER BYoption

The index can also be used even if the ORDER BY does not match the index exactly, as long as all of the unused portions of the index and all the extra ORDER BY columns are constants in the WHERE clause.

Here is the example i used the sorting inn my own

Selecte * from table order by  FIELD ( column_name , ‘ 8′,’7′,’2′,’1′,’5′,’4’);

I think it also help for you guys 🙂 enjoy  the Day

By karuppasamy11486 Posted in Mysql, php

determine a string is base64_encoded or not in php

I can easily find out if a string is encoded in base64? Basically, if the string is base64 encoded It must be an exact multiple of 4 characters. (Remember that it may end in1, 2 or 3 ‘=’ characters.) We can check this using the regular expression

Here is the example what i do

if(preg_match(‘%^[a-zA-Z0-9/+]*=%’, $data))
$data1 = $data;
$data1 = base64_encode($data);


I hope this help you a little bit 🙂

Create a user in mysql

To create a new user  in mysql using grant

GRANT ALL ON my_db.* TO ‘my_user’@localhost IDENTIFIED BY ‘my_pass’;

To grand all permission to the user

GRANT ALL ON my_db.* TO ‘username’@’localhost’;

For more detailed information on how to use the GRANT statement, please visit the ‘MySQL grant‘ article in your hosting encyclopedia or the MySQL documentation (

By karuppasamy11486 Posted in Mysql Tagged