Monday, April 14, 2014

TinyMCE Plugin WordPress

WYSIWYG, tentunya sudah sering kita dengar istilah ini, merupakan kepanjangan dari What You See Is What You Get. Kalau dari perspektif user ini berarti kemudahan membuat, mengubah atau menghapus layout atau konten sebuah dokumen dimana user tinggal klik dan drag maka usermendapatkan apa yang diinginkan. Istilah ini erat kaitannya dengan editor HTML yang akan kita bahas berikut ini. Dalam artikel ini, saya akan tunjukkan bagaimana tinyMCE bekerja pada sebuah CMS yang banyak dipakai saat ini yaitu CMS WordPress.

TinyMCE pada WordPress


(TinyMCE Plugin WordPress) Salah satu keunggulan WordPress adalah kemudahan dalam mengedit sebuah konten di halaman backend yang dia miliki. Ini tidak terlepas dari editor HTML yang dia pakai yaitu TinyMCE. Editor HTML ini merupakan proyek open source dari Moxiecode Systems AB dengan lisensi LGPL. Satu fitur yang membuatnya sangat disukai adalah dukungan kustomisasi yang sangat luas. Mulai dari menambah dan mengurangi fitur sampai pada pembuatan plugin atau theme untuk jenis editor ini.

Tidak semua plugin yang dimiliki TinyMCE diimplementasikan dalam core WordPress. Hanya 7 plugin bawaan editor yang dipakai oleh wordpress diantaranya adalah directionality, fullscreen, inlinepopups, media, paste, spellchecker, tabfocus. Selain itu ada beberapa plugin editor yang WordPress custom sendiri yaitu wordpress, wpdialogs, wpeditimage, wpfullscreen, wpgallery, wplink.

[caption id="attachment_353" align="aligncenter" width="299"]tinymce-whendy-blog tinymce-whendy-blog[/caption]

Mengaktifkan hidden button


Dalam implementasinya semua button edit tidak ditampilkan oleh WordPress. Button-button edit seperti hr (horizontal rule), sub (subscript)dan sup (superscript) sudah ada dalam TinyMCE-nya WordPress tapi hanya memang tidak diaktifkan oleh WordPress. Source code dibawah ini merupakan cara kita mengaktifkan button-button itu.
function my_mce_buttons($buttons) {
/**
* Add in a core button that's disabled by default
*/
$buttons[] = 'sup';
$buttons[] = 'sub';
return $buttons;
}
add_filter('mce_buttons', 'my_mce_buttons');

Untuk mengaktifkan button-button yang ter-hidden, dapat dilakukan dengan cara menambahkan value button pada sebuah array yang kita filterpada hook mce_buttons. Pada contoh, saya menambahkan button superscript dan subscript yang saya tampilkan pada baris pertama editor wordpress(mce_buttons). Selain mce_button, core WordPress juga menyediakan filter hook mce_button_2, mce_button_3, dan mce_button_4untuk memposisikan button pada baris 2,3 dan 4 editor. Berikut adalah list button yang saya dapat dari dokumentasinya TinyMCE tentang buttoncontrol:
bold, italic, underline, strikethrough, justifyleft, justifycenter, justifyright, justifyfull, bullist, numlist, outdent, indent, cut, copy, paste, undo, redo, link, unlink, image, cleanup, help, code, hr, removeformat, formatselect, fontselect, fontsizeselect, styleselect, sub, sup, forecolor, backcolor, forecolorpicker, backcolorpicker, charmap, visualaid, anchor, newdocument, blockquote, separator ( | is possible as separator, too)

Menambahkan TinyMCE Table pada WordPress Editor


Pembuatan tabel konten WordPress sering kali menyulitkan user yang belum mengerti struktur HTML. Tidak ada button pada editor WordPress yang dapat memudahkan user dalam membuat struktur tabel pada konten post WordPress. Mau tidak mau untuk membuat struktur tabel, user harus mengerjakannya secara manual dengan menulis kode-kode HTML pada tab “HTML”.

Ada dua solusi yang biasanya dilakukan developer untuk memudahkan user membuat struktur tabel, diantaranya adalah membuat shortcodewordpress untuk generate table konten atau menambahkan plugin table yang sudah dimiliki oleh tinyMCE. Saya kira untuk masalah ini, solusi kedua adalah yang paling bisa digunakan oleh user awam.

Pada subbab ini, Saya akan mencoba menerangkan bagaimana caranya kita menambahkan plugin table tinyMCE pada editor WordPress.

1. Download versi terbaru tinyMCE. Pada saat artikel ini ditulis, versi terakhir tinyMCE adalah 3.5.7. TinyMCE bisa kita dapatkan pada link ini.

2. Semua plugin tinyMCE akan terletak pada folder tinymce/jscripts/tiny_mce/plugins/. Seperti yang tampak pada gambar berikut ini.

[caption id="attachment_354" align="aligncenter" width="550"]tinymce-whendy-blog tinymce-whendy-blog[/caption]

Copas folder table pada plugin atau theme WordPress yang akan Anda buat, dalam contoh saya akan meletakkan table folder pada theme saya sendiri yang terletak pada /gootheme/feature/editor/table

[caption id="attachment_355" align="aligncenter" width="222"]tinymce-whendy-blog tinymce-whendy-blog[/caption]

3. Kemudian pada function.php theme, tambahkan source code berikut untuk menampilkan beberapa button table dan load plugin table.
add_action('admin_init', 'custom_mce');
function custom_mce() {
if (current_user_can('edit_posts') && current_user_can('edit_pages')) {
add_filter('tiny_mce_before_init', 'custom_mce_before_init');
add_filter('mce_buttons_3', 'custom_mce_button_3');
add_filter('mce_external_plugins', 'custom_mce_plugin');
}
}

function custom_mce_before_init($inits) {
$inits['url_theme'] = THEME_URI;
return $inits;
}
/**
* Add in a table button
*/

function custom_mce_button_3($buttons) {
array_push($buttons, '|', "table");
array_push($buttons, '|', "delete_table");
array_push($buttons, '|', "delete_col");
array_push($buttons, '|', "delete_row");
array_push($buttons, '|', "col_after");
array_push($buttons, '|', "col_before");
array_push($buttons, '|', "row_after");
array_push($buttons, '|', "row_before");
array_push($buttons, '|', "row_props");
array_push($buttons, '|', "cell_props");
array_push($buttons, '|', "split_cells");
array_push($buttons, '|', "merge_cells");

return $buttons;
}

/**
* Load table file plugin
*/

function custom_mce_plugin($plugins) {
$plugins["table"] = THEME_URI . '/features/editor/table/editor_plugin.js';
return $plugins;
}

Ada tiga filter hook MCE yang setidaknya saya gunakan pada source code diatas. Pertama adalah filter tiny_mce_before_init yang akan melewatkan parameter kita pada core plugin editor yang kita buat. Kedua adalah filter mce_buttons_3 yang akan menambahkan beberapabutton plugin editor. Terakhir filter mce_external_plugins yang akan me-load file plugin, dalam contoh adalah editor_plugin.js yang dimilikitable plugin TinyMCE.

[caption id="attachment_356" align="aligncenter" width="550"]tinymce-whendy-blog tinymce-whendy-blog[/caption]

Ada dua tips yang Saya berikan pada artikel diatas yaitu mengaktifkan button-button yang di hidden Wordpress dan menambahkan plugin editor tinyMCE. Ada satu artikel lagi yang ingin Saya share pada para pembaca setia BisaKomputer, yaitu cara membuat plugin TinyMCE sendiri pada editor WordPress. Menurut Saya dengan menguasai beberapa tips custom editor TinyMCE pada WordPress yang saya sebutkan diatas, kita dapat meng-custom atau bahkan menciptakan sendiri lingkungan editing yang mungkin akan menambah nilai jual pada themes WordPress.

Friday, April 11, 2014

Cara Membuat Bootable USB Dengan Unetbootin Di Windows

Cara Membuat Bootable USB dengan Unetbootin Di Windows sangat lah mudah dari Cara Membuat Bootable USB Dengan Command Line Windows. Pertama anda sudah memiliki software Unetbootin terlebih dahulu, jika belum punya bisa di download langsung disini . Jika sudah, ada langkah2 Cara Membuat Bootable USB Dengan Unetbootin.

Buka / Click Double Unetbootin

unetbootin-1

Jika sudah Maka akan muncul tampilan seperti ini

unetbootin-2

Di situ terdapat Dua Radio button

  1. Distribusi

  2. ISO


Pada bagian ini pilih ISO / Radio button ke 2. Setelah itu Klik browse pada bagian kanan, untuk memilih / select file iso yang anda punya ( anda akan membuat Bootable OS apa ?)  :lol:

Setelah terpilih, lakukan pengaturan selnjutnya padah bagian bawahnya. Untuk Type pilih / selected Drive USB, Drive disini adalah tujuan lokasi (flashidisk) yang akan dilakukan instalasi boot, Setelah sudah semua klik Ote tatak  :lol: .. Tunggu sampai selesai

Untitled

 

Nah jadi lah sudah Cara Membuat Bootable USB Dengan Unetbootin Di Windows.

 

Cara Membuat Bootable USB Dengan Command Line Windows

Bagi kamu pengguna netbook yang tidak dilengkapi dengan DVD-ROM, tentunya menginstall Windows melalui Bootable USB merupakan pilihan utama. Dari berbagai cara membuat bootable USB Windows, kebanyakan akan mengharuskan kamu untuk menggunakan software tambahan. Yup..cara tersebut memang mudah. Tetapi di tutorial ini akan mengajarkan kepada kamu Cara Membuat Bootable USB Dengan Command Line Windows.

Pertama siapkan dulu USB flashdisk yang akan digunakan beserta file ISO installer Windows. Setelah itu tancapkan flashdisk di PC, dan setelah terdeteksi buka Run (Win + R) -> ketikkan diskpart -> Enter

membuat_usb_instalasi_windows_1

Window CMD diskpart akan terbuka, ketikkan list disk -> Enter

membuat_usb_instalasi_windows_2

Lihat Disk berapa USB flashdisk kamu. Kamu bisa mengetahuinya dengan mudah melalui ukuran (size) flashdisk tersebut. Dalam contoh ini, USB flashdisk WinPoin adalah Disk 3.

membuat_usb_instalasi_windows_3

Setelah itu, ketikkan select disk 3 (ganti 3 dengan ID dari urutan disk USB flashdisk kamu) -> Enter

membuat_usb_instalasi_windows_4

Ketikkan clean lalu tekan Enter untuk menghapus partisi, file system, dan data yang masih tersimpan di USB Flashdisk. Pastikan proses cleaning diskpart tersebut berhasil.

membuat_usb_instalasi_windows_5

Setelah itu ketikkan create partition primary -> Enter. Pastikan proses pembuatan partisi berhasil.

membuat_usb_instalasi_windows_6

Setelah itu jadikan partisi tersebut sebagai active dengan cara mengetikkan active ->Enter. Pastikan partisi sudah berhasil di set sebagai active.

membuat_usb_instalasi_windows_7

Format partisi tersebut dengan file system FAT32. Caranya cukup ketikkan format fs=fat32 label=febian quick -> Enter (ubah nama label dengan nama yang kamu inginkan)

membuat_usb_instalasi_windows_8

Setelah berhasil, maka flashdisk kamu sudah menjadi partisi primary yang aktif dan bootable. Close window diskpart dengan mengetikkan exit.

Kini kamu tinggal mount saja file ISO installer Windows dan copy semua isinya ke flashdisk tersebut.

membuat_usb_instalasi_windows_9

Setelah semua isi tercopy kedalam flashdisk, maka flashdisk tersebut siap untuk kamu gunakan untuk menginstall Windows.

membuat_usb_instalasi_windows_15

Akhirnya kamu sudah berhasil membuat bootable USB Windows tanpa menggunakan software tambahan apapun. Selamat!  :-D

Ada pun Cara Membuat Bootable USB Dengan Unetbootin Di Windows

Deny a user by IP Address

Deny a user by IP Address - There may come a time when you unfortunately need to ban someone from visiting your website completely.




This is very easy to do using htaccess and can be useful if there is a spammer or disgruntled member attacking your site (something which unfortunately happens a lot to forum and blog owners).

To ban someone completely all you need to do is add the following code to your .htaccess file.

Simply replace the ip address below with the ip of the person you want to ban
#ban users from visiting the site
order allow,deny
deny from 123.45.6.7
allow from all

If you want to ban more people you simply add more lines, like this :
#ban users from visiting the site
order allow,deny
deny from 123.45.6.7
deny from 987.65.4.3
deny from 56.45.34.456
allow from all

Change the Default Directory Page

Change the Default Directory Page - When you load a directory on the web, for example www.yoursite.com or www.yoursite.com/articles/, the apache server usually looks for the index.html file.

If it can’t find that it will look for index.php or index.cgi. Index.html is usually the page with the highest priority and the one which is loaded first.

It is possible to change the default directory index page. Say, for example, you wanted visitors to go to notice.html instead of index.html. All you have to add to your .htaccess file is
DirectoryIndex notice.html

This can be extended so that the server looks for other files if it cannot find the first one.
DirectoryIndex notice.html index.cgi index.php index.html

Priority goes from left to right. So the server would look for notice.html. If that file is not there it will look for index.cgi, then index.php and then index.html.

You can do to this within any directory on your site. Simply upload an .htaccess file with the above code. Remember, this will supercede the .htaccess file at the root of your domain.

How to Stop Directory Listing

How to Stop Directory Listing - If you have a lot of files in a directory but no index file, your server will list all the files in that server.

This can cause a lot of problems. For example, one of the most common directories which webmasters forget to hide is the images folder. This allows everyone to view all the images in their images folder. This isn’t usually a major problem though you may have more important files in a directory, perhaps important documents or software.

You can stop this from occurring from using the following code :
IndexIgnore *

The * is a wildcard and stops the server from listing any type of file. You can of course only stop certain files or file types from being listed.

For example :
IndexIgnore *.gif *.jpg *.png accounts.doc

The above code would stop all gif, jpg and png graphics files from being listed.

The accounts.doc document would be blocked too however all other .doc files would be shown.

Basically the IndexIgnore command lets you decide what files in a directory visitors can see.

You can upload an .htaccess file for every directory you want to stop people viewing but it’s more practical to place everything in your main .htaccess file (ie. your root .htaccess).

To do this all you need to do is include the path to the folder(s) you want to protect.

So to block people viewing the files at www.yoursite.com/images/ and www.yoursite.com/banners/ you would the following code to your .htaccess :
IndexIgnore /images/*
IndexIgnore /banners/*

How to edit file htaccess

How to edit file htaccess - Before you upload an .htaccess file to your server, make sure there is not already one there. Your host panel or perhaps a script you have uploaded may have already changed the htaccess for some reason so you don’t want to overwrite it as doing so could change something important on your site.

Htacess Changes in Cpanel


For example, in cpanel, you can setup 301 redirects very easily but this tool is simply a script which changes the .htaccess for you.

So even though you may not realise it, when you use the redirect script via cpanel, it updates your .htaccess file for you and it’s the .htaccess file which controls the redirect for you (the redirect tool just makes it easier for those who are not familar with .htaccess).

Htacess Created from Cpanel


So if there is an .htaccess file on the server already, you want to ensure that you download the htaccess file and then edit it before reuploading. This will ensure that nothing you or someone else has setup previously is changed.

If there is no .htaccess file there then you need to create one. Thankfully, this is very easy to do. All you need to do is open a text editor and save a blank document as .htaccess. Save the file exactly as it is stated there in bold ie. there is no writing before the extension. You need to save it as .htaccess and not htaccess.txt or document1.htaccess or whatever.

Htacess Upload to Server


When uploading you should always :

  • Upload in ASCII mode, not binary

  • CHMOD the file to 644 (this isn’t absolutely necessary per say but it’s advisable, it means your server can access it but it can’t be seen via a browser).


Htacess Comment Organization


Also, after editing your .htaccess file several times it may look a little complicated so I recommend adding a comment above the longer parts or sections of code so that you know what each section is for when you look at the file again at a later date.

Htacess Comment #


To add a comment to the htacess file you simply start the line with #, any code written after the # in the start of the line will not be executed.

Htacess Comment Line Examples


# Index Page
# Redirects 301 for Recent Pages
# Errors 404 Pages


This is simply a reference for you in the future (and anyone else who may be working on your website ie. co-admin or whatever).

Edit the .htaccess File Reference


Comment Organization: When you need to create, say more that 15-20 redirect, 404 errors, custom htaccess coding it can get confusing and a waste of your time searching for the line, especially if you or others have not been into the htaccess file for a while. Extra time grouping related htaccess code lines can save some aggravation search time.

Htaccess Password Protect a Directory

Htaccess Password Protect a Directory is easy to do, all you have to do is :

  1. Add some code to your .htaccess file

  2. Create a file called .htpasswd

  3. Select a username and generate an encrypted password and then add them to your .htpasswd file


Code to add to your Htaccess

You need to add the following code to your .htaccessfile.

AuthType Basic
AuthName "Name of your secure area"
AuthUserFile /fullpath/to/your/directory/.htpasswd
require valid-user


You need to edit the file accordingly.


  • Name of your secure area = You can call this anything you want ie. Secure Area or Members Area or whatever.

  • Full Path To Your Directory = This is the absolute path to the directory where your .htpasswd file is saved.


Here’s an example :


AuthType Basic
AuthName "Private Area"
AuthUserFile /home/mysite/.htpasswd
require valid-user


Create a file called .htpasswd

You create a .htpasswd file the same way you created the .htaccess file. All you need to do is create a blank document and save it as .htpasswd.

For security reasons, it is best to place this file above the root of your domain ie. place it in something like /home/mysite/ instead of /home/mysite/public_html.

Create a username and password

The username and password added to your .htpasswd file is in the format :

username:encryptedpassword

So my generated password might be something like

Kevin:nDh54k4Nc.C5c

So how do I encrypt my password in this way?

Well there are a number of ways but the quickest and easiest is to use one of the many encryption sites on the web.

Just use any of the scripts below to generate your encrypted password.

Once you have your username and password, simply add the line to your .htaccess file.

Now go and test it out and see if your directory is now password protected :)

Password Protect a Directory Comments



  • To give additional users access to a directory simply add another line with a username and encrypted password

  • Only the password is encrypted, the username is not encryped

Htaccess Supersession



Htaccess Supersession - The most common place to upload an .htaccess file is the root ie. the home page of your website. This is because so many things can be controlled from the top level.

However, there are many occasions when you will need to upload an .htaccess file to a sub directory.

Htaccess Password Protect


For example, if you want to password protect a directory you need to place the .htaccess file in the directory you want to protect.

The important thing to remember is that any code in a subdirectory .htaccess file supercedes the one in the directory above.

However, it only supercedes it when there is a clash. I’ll explain this with an example.

Lets say your root .htaccess and your subdirectory .htaccess file both state how a 404 error should be treated.

If someone tries to view a page which has been deleted within the subdirectory then the user will be redirected according to the rule stated in the subdirectory .htaccess file ie. it supercedes the htaccess on the home page.

If, however, the user tries to view an incorrect url in the root directory, the root .htaccess file will dictate what will happen.

About Htaccess



About Htaccess - The htaccess file is a powerful tool which can redirect users, ban visitors, password protect directories and much more.

Htaccess Coding


Yet it remains something which intimidates many webmasters because of how complicated the code is.

However, just like any programming language, once you have used it a while it becomes more familiar to you.

I hope I can convince some people of this through this HtaccessBasics.co website.

Kevin Muldoon

How to Redirect your 404 error to a Custom Page

How to Redirect your 404 error to a Custom Page - A 404 error message is the standard HTTP standard response code which is returned when the visitor cannot communicate with the server. Visitor gets a standardized undesirable 404 Error Page

This is a very common error on the web and it occurs when you are trying to visit a page which has either been deleted or has been moved somewhere else.

For example, if you change the structure of your website and move a certain directory to a different part of your site, anyone trying to visit the old page url will get a 404 error message.

404 Error Messages


A 404 error is pretty much lost traffic with in your website. You have managed to get the visitor there with your SEO efforts but a changed page over site results in the visitor getting the generic server 404 error messages. A lot of standard 404 messages are useless and do not even refer your visitor back to the homepage. A 404 error message usually looks something like this :
Not Found

The requested URL /index.php was not found on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
Apache/2.2.9 (Unix) mod_ssl/2.2.9 OpenSSL/0.9.7a mod_bwlimited/1.4 PHP/5.2.6 Server at yourwebsite.com Port 80

404 Error Message Reality


If a visitor comes to your site and sees a standard 404 error message it’s unlikely they will make the effort to see any part of your site. Therefore it is very important to create a 404 page on your site and redirect traffic from incorrect urls.

Thankfully, htaccess makes this very easy. First of all you need to create a 404 error page. So for example, you would create a page at http://www.yoursite.com/404.php which says something like :
It appears you are looking for something which isn’t there. Either you have entered an incorrect URL or we have messed up. Why not visit our home page or alternatively, search for what you are looking for in the search box below.

Whilst a 404 error page does not send the visitor to the exact page they want, it can be used for a better presentation of your website. Offering the visitor other page options, alternate choice to go back and generally point them in the right direction is better than them leaving ASAP.

The 404 .htaccess error page keeps them on your site pages so that they are more likely to stay and find what they want on your site.

htaccess 404 Error Code


Once you have your 404 page setup, all you need to do is send visitors of incorrect url’s to this page. To do this just add the following line to your .htaccess file :

ErrorDocument 404 /404.php

Most often, the .htaccess file will be in the home root public_html folder on your server. This can change, for an example if you run you site or blog out of a specific folder within the public_html.

Alternately, You can place the 404 error template anywhere you want in a folder. For example you could place all error messages in a folder called errormessages refererring the 404 error to the url of the page.

ErrorDocument 404 /errormessages/404.php

That’s all there is to it.

Now when a visitor views an incorrect url on your site they will see your custom 404 error message.

404 Error Messages Comments


Don’t have 404 error handling system? Set up a .htaccess file with quick ErrorDocument 404 code link sending your visitor back to the index home page. When you have more time code a custom 404 error page with the information you want.

ErrorDocument 404 /index.html Adjust code to reflect your home page file name: / “to your index page” You can test if 404 error redirect is working by going to a page within your site, url other than home page, type in a few junk characters in the addresses file box name .. and if 404error working browser sends you or you visitor to the home page. Good quick temporary fix!

Page Errors Adsense: If your operating your sites with Google(R) Adsense, you probably seen a larger focus on page errors in your account with any crawler errors listing of your bad site(s) page . Users don’t like 404 page errors as it decreases the user experience. Do a little revenue optimization and site health by solving page errors one by one … best use a 301 redirect for each page error in your htaccess file

404 error Reference, Notes, Tips


A 404 error is classified page as “Not found” or non existent url. A 410 error is a “Gone” response code.

HTTP response code 404 tells both browsers and search engines that your page doesn’t exist. Page content and ranking position will be lost, neither the page be crawled or indexed, by your top Google, Bing or Yahoo search engines.

How to setup a 301 Redirect


How to setup a 301 Redirect





A 301 HTTP response status code is a way of telling search engines that a page, pages, directory or entire website has been permanently moved to another place on the web.

Htacess Redirect


This is very useful if you have changed the structure of your websites url’s or if you have moved domain. You can also redirect your entire site.

Whereas a 301 code tells search engines that something has been permanently moved, a 302 code tells search engines that something has been temporarily moved. This is useful if you only want to redirect a page for a short period of time. To do a 302 redirect simply change the 301 part to 302.

You can also use 303, which is means ‘seeother’ and the page has been replaced by something else. Again, to do this simply substitute 301 with 303 in the tutorials below.

How to setup a 301 Redirect


The basic code for redirecting is :

Redirect 301 old_location new_location

The old location of the file has to be the absolute path from the root of your server. The new location should use http.

Htacess to Redirect Pages


Saving your page’s ranking, search position and it’s indexed age are important to maintaining your sites traffic. Moving one or more files into a new named folder can result in better website organization or to simplify your sites categories but if you don’t redirect the crawlers to index your new page(s) then your new pages will be sent back in the searches like a newly created webpage pages.

Htacess SEO Redirect


Picking a strong folder name or page name based on top searched keywords is one way to SEO improve your keyword focus and page ranking.

So for example, if you want to move a file called productreview.html from the root of your site to a subdirectory called products you would use :

Redirect 301 /productreview.html http://www.yoursite.com/products/productreview.html

How to setup a 301 Redirect

If you have moved your domain to another site you may want to redirect the whole site.

To so this you simply use the following code:

Redirect 301 / http://www.newdomainname.com/

Htaccess Basics


What is htaccess?





Htaccess Basics - Hypertext Access, commonly shortened to htaccess, is a powerful configuration file which controls the directory it is placed in and all the subdirectories underneath it.

Htaccess is a useful feature allowing webmasters to control how many aspects of their website workings.

Htacess to Redirect Pages


You can use 301 redirect for pages not found; be it for dead pages, indexed page errors or old pages or applied to folders changes.

Furthermore, you can with one line of code change the language extensions of pages, rewrite urls for better keyword ranking presence, password protect directories, Error 404 Document redirect and much much more.

In this htaccess guide I will show you some of the basic htaccess tricks and tips which will help you with your website problems. Updating and implementing better keyword redirects can further improve your sites SEO ranking and page position.

So what is an htaccess File?


The htaccess file is a configuration file which is used on Apache based web servers to control many features of the server. The file itself is just a small basic text file and can be edited, via notepad, or your hosts file manager, thru c-panel redirects or alternatively you can download the .htaccess file from your server’s home public_html folder, edit it and reupload it FTP using programs like FileZilla.

If you have installed a script before then chances are you have had to edit the .htaccess file at one point or another. The .htaccess file gives you a lot of control and lets you easily redirect pages, password protect directories and much more. Before I go through some tutorials which show you how to use htaccess, I think it is necessary to show you how you edit the file.

Where is the .htaccess file Located?


The first thing you need to do is find out if your host actually lets you edit htaccess files. Because of security problems which can arise, many hosts stop their customers from editing it the .htaccess file. Therefore you should check the Frequently Asked Questions area of your host to see if you have permission to edit the file (failing that, email them).

Some operating systems may not show the .htaccess file on your computer so you may need to make sure settings show hidden files as well. Likewise some FTP Clients will not show the .htaccess file when you connect to your host so you need to make sure that your FTP is set up to show hidden files too (I personally use FileZilla and that shows .htaccess by default).

Example of htaccess File: Here is how a htacess file looks and is ready for editing in Dreamweaver CS ..

example_file_htaccess

Note if creating a new htaccess file be sure the file has a dot in front of the file name .htaccess

Htaccess Power: Play it Safe than Sorry


The .htaccess gives you a lot of control over what happens on your site but accidents do happen. Just forgetting to start your redirect url with a forward slash “/” can crash your whole site, it can be some nerve racking panicked moments to just recover, let alone fix any redirect issues!

So make sure you keep a backup or best create a copy of the htacess file of the last working .htaccess file you used before attempting to modify it in anyway. This way you can recover quickly from a site crash!

Htaccess is also extremely sensitive. A missing semi colon, incorrect letter or an extra backslash can mess everything up so you need to make sure that what you enter is correct 100%.

Don’t let this scare you off though, as long as you take your time and make sure everything is input correctly you can enter just a few lines to your websites htaccess file to achieve things which most php scripts take a page to do.

To learn more about htaccess simply click on one of the articles at the right hand side. Good luck htaccess coding :)

Htaccess recommends:Beginner-Sql-Tutorial.com
Htaccess recommends:Plsql-Tutorial.com
Htaccess recommends:TechBooksforFree.com

Htaccess: Comments, Reference, Notes, Facts, Ideas, Tips


Htaccess 404 Error


Url request produces page “Not Found” reply. Means resource could not be found at the time. Permits future requests. Solution: Fix or redirect request to active resource or page.

Htaccess 301 Errors


SEO organizing, fine tuning, folder renaming and redirecting a large number of pictures, objects or pages can be time consuming. Consider using a htacess generator to help you simplify your redirect task.

Htaccess 404 Error Option


Don’t have 404 error handling system? Set up a .htaccess file with quick ErrorDocument 404 code link sending your visitor back to the index home page. When you have more time code a custom 404 error page with the information you want.

Htaccess 404 Error Test


ErrorDocument 404 /index.html Adjust code to reflect your home page file name: / “to your index page” You can test if 404 error redirect is working by going to a page within your site, url other than home page, type in a few junk characters in the addresses file box name .. and if 404error working browser sends you or you visitor to the home page. Good quick temporary fix!

No Htaccess 404 Errors: Google


Page Errors Adsense: If your operating your sites with Google(R) Adsense, you probably seen a large focus on crawler page errors in your account listing “pages not found 404 errors” and other crawler errors of bad site page(s). visitor’s don’t like 404 page errors as it decreases the user experience. Do a little revenue optimization and site health by solving page errors one by one … best use a 301 redirect for each page error in your htaccess file

Htaccess 404 And 410 Errors


A 404 error is classified page as “Not found” or non existent url. A 410 error is a “Gone” response code.

HTTP response code 404 tells both browsers and search engines that your page doesn’t exist. Page content and ranking position will be lost, neither the page be crawled or indexed, by your top Google, Bing or Yahoo search engines.

Htaccess (Hypertext Access) Errors


Htaccess (Hypertext Access) typing error: Copy and paste the file name where possible: Hypertext Access file name is shortened to HTaccess … some refer to it as a “hta access” file which will generate the wrong spelling with 2 “a’s”.

Htaccess (Hypertext Access) Power


The power of Htaccess is that you can rename long file names or folders urls’s into shorter urls, get creative, choose better keyword based names for improved seo and traffic ranking. Htaccess (Hypertext Access) good for transforming dynamic ?generated=page&URL’s into htmllinks, 301 and 404 redirect changed or missing pages, prevent those hot-linkers and doing automatic language translation.

Htaccess (Hypertext Access) Web Page Clean Up by Renaming


Using the Htaccess file with 301 Redirect is a great powerful tool that allows one to clean up old website file names. A little htacess housekeeping can eliminate the previous use of any uppercase letters, reduce use of blank spaces in file names or any funky characters you don’t want. Old web sites urls once cleaned up will benefit by being up to-date and better readable which can result in improved seo and traffic ranking.

When to Fix Htaccess (Hypertext Access) Errors


Fixing HTacess website 404 errors is in the urgent status but not necessarily an emergency! Your website does not die but it feels the pain of missed traffic. Best start with the largest redirect errors and work down the list.

Force users to use the WWW or Non-WWW version of your domain

Force users to use the WWW or Non-WWW version of your domain. To avoid duplicate content in search engines you can force users to use either the www or the non-www version of your website domain.

This avoids search engines such as Google indexing two versions of your domain, something which is quite common because people link to both www and on-www versions of a domain (known as the www/non-www canonical issue).

It really doesn’t matter if you use www.yoursite.com or yoursite.com. I personally use www on most sites I own however many people prefer to drop it, it’s really up to you.

Force users to use http://www.yoursite.com

To force users to use the www version of your domain all you have to do is add the following code to your .htaccess file (just replace yoursite.com with your domain name).


# Redirect non-www urls to www
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.yoursite\.com
RewriteRule (.*) http://www.yoursite.com/$1 [R=301,L]


Alternatively you can use :


# Redirect non-www urls to www
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example\.com [NC]
RewriteRule (.*) http://www.example.com/$1 [R=301,L]


Force users to use http://yoursite.com

To force users to use the non www version of your domain all you have to do is add the following code to your .htaccess file (just replace yoursite.com with your domain name).


# Redirect www urls to non-www
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.yoursite\.com [NC]
RewriteRule (.*) http://yoursite.com/$1 [R=301,L]


Alternatively you can use :


# Redirect www urls to non-www
RewriteEngine on
RewriteCond %{HTTP_HOST} !^example\.com
RewriteRule (.*) http://example.com/$1 [R=301,L]


Notes about this technique

Many popular scripts, particular content management systems (CMS’s) edit the .htaccess file and add their own redirection so you may not have to add any of the code noted above. Infact, by adding the redirection code noted above you could actually mess things up.

For example, the popular blogging script WordPress adds redirection to the .htaccess file. You simply chose the correct domain name in the admin panel and it takes care of everything else. And if you do add the code to the .htaccess file it messes things up a little. It does still redirect non-www to www (and vice versa) but it just redirects the visitor to the home page (ie. http://yoursite.com/folder1/page1 would redirect to http://yoursite.com/ instead of http://www.yoursite.com/folder1/page1).

If this sounds a little confusing, don’t worry. Just remember that certain scripts already apply a redirection and so trying to add a redirection code to the .htaccess file can mess things up, at the very least it will unlikely work the way you want it to.

String Functions SQL

String Functions SQL

are used primarily for string manipulation. The following table details the important string functions:











































































































































































































NameDescription
ASCII()Returns numeric value of left-most character
BIN()Returns a string representation of the argument
BIT_LENGTH()Returns length of argument in bits
CHAR_LENGTH()Returns number of characters in argument
CHAR()Returns the character for each integer passed
CHARACTER_LENGTH()A synonym for CHAR_LENGTH()
CONCAT_WS()Returns concatenate with separator
CONCAT()Returns concatenated string
CONV()Converts numbers between different number bases
ELT()Returns string at index number
EXPORT_SET()Returns a string such that for every bit set in the value bits, you get an on string and for every unset bit, you get an off string
FIELD()Returns the index (position) of the first argument in the subsequent arguments
FIND_IN_SET()Returns the index position of the first argument within the second argument
FORMAT()Returns a number formatted to specified number of decimal places
HEX()Returns a string representation of a hex value
INSERT()Inserts a substring at the specified position up to the specified number of characters
INSTR()Returns the index of the first occurrence of substring
LCASE()Synonym for LOWER()
LEFT()Returns the leftmost number of characters as specified
LENGTH()Returns the length of a string in bytes
LOAD_FILE()Loads the named file
LOCATE()Returns the position of the first occurrence of substring
LOWER()Returns the argument in lowercase
LPAD()Returns the string argument, left-padded with the specified string
LTRIM()Removes leading spaces
MAKE_SET()Returns a set of comma-separated strings that have the corresponding bit in bits set
MID()Returns a substring starting from the specified position
OCT()Returns a string representation of the octal argument
OCTET_LENGTH()A synonym for LENGTH()
ORD()If the leftmost character of the argument is a multi-byte character, returns the code for that character
POSITION()A synonym for LOCATE()
QUOTE()Escapes the argument for use in an SQL statement
REGEXPPattern matching using regular expressions
REPEAT()Repeats a string the specified number of times
REPLACE()Replaces occurrences of a specified string
REVERSE()Reverses the characters in a string
RIGHT()Returns the specified rightmost number of characters
RPAD()Appends string the specified number of times
RTRIM()Removes trailing spaces
SOUNDEX()Returns a soundex string
SOUNDS LIKECompares sounds
SPACE()Returns a string of the specified number of spaces
STRCMP()Compares two strings
SUBSTRING_INDEX()Returns a substring from a string before the specified number of occurrences of the delimiter
SUBSTRING(), SUBSTR()Returns the substring as specified
TRIM()Removes leading and trailing spaces
UCASE()Synonym for UPPER()
UNHEX()Converts each pair of hexadecimal digits to a character
UPPER()Converts to uppercase


ASCII(str)


Returns the numeric value of the leftmost character of the string str. Returns 0 if str is the empty string. Returns NULL if str is NULL. ASCII() works for characters with numeric values from 0 to 255.
SQL> SELECT ASCII('2');
+---------------------------------------------------------+
| ASCII('2') |
+---------------------------------------------------------+
| 50 |
+---------------------------------------------------------+
1 row in set (0.00 sec)

SQL
> SELECT ASCII('dx');
+---------------------------------------------------------+
| ASCII('dx') |
+---------------------------------------------------------+
| 100 |
+---------------------------------------------------------+
1 row in set (0.00 sec)


BIN(N)


Returns a string representation of the binary value of N, where N is a longlong (BIGINT) number. This is equivalent to CONV(N,10,2). Returns NULL if N is NULL.
SQL> SELECT BIN(12);
+---------------------------------------------------------+
| BIN(12) |
+---------------------------------------------------------+
| 1100 |
+---------------------------------------------------------+
1 row in set (0.00 sec)


BIT_LENGTH(str)


Returns the length of the string str in bits.
SQL> SELECT BIT_LENGTH('text');
+---------------------------------------------------------+
| BIT_LENGTH('text') |
+---------------------------------------------------------+
| 32 |
+---------------------------------------------------------+
1 row in set (0.00 sec)


CHAR(N,... [USING charset_name])


CHAR() interprets each argument N as an integer and returns a string consisting of the characters given by the code values of those integers. NULL values are skipped.
SQL> SELECT CHAR(77,121,83,81,'76');
+---------------------------------------------------------+
| CHAR(77,121,83,81,'76') |
+---------------------------------------------------------+
| SQL |
+---------------------------------------------------------+
1 row in set (0.00 sec)


CHAR_LENGTH(str)


Returns the length of the string str measured in characters. A multi-byte character counts as a single character. This means that for a string containing five two-byte characters, LENGTH() returns 10, whereas CHAR_LENGTH() returns 5.
SQL> SELECT CHAR_LENGTH("text");
+---------------------------------------------------------+
| CHAR_LENGTH("text") |
+---------------------------------------------------------+
| 4 |
+---------------------------------------------------------+
1 row in set (0.00 sec)


CHARACTER_LENGTH(str)


CHARACTER_LENGTH() is a synonym for CHAR_LENGTH().


CONCAT(str1,str2,...)


Returns the string that results from concatenating the arguments. May have one or more arguments. If all arguments are non-binary strings, the result is a non-binary string. If the arguments include any binary strings, the result is a binary string. A numeric argument is converted to its equivalent binary string form; if you want to avoid that, you can use an explicit type cast, as in this example:
SQL> SELECT CONCAT('My', 'S', 'QL');
+---------------------------------------------------------+
| CONCAT('My', 'S', 'QL') |
+---------------------------------------------------------+
| SQL |
+---------------------------------------------------------+
1 row in set (0.00 sec)


CONCAT_WS(separator,str1,str2,...)


CONCAT_WS() stands for Concatenate With Separator and is a special form of CONCAT(). The first argument is the separator for the rest of the arguments. The separator is added between the strings to be concatenated. The separator can be a string, as can the rest of the arguments. If the separator is NULL, the result is NULL.
SQL> SELECT CONCAT_WS(',','First name','Last Name' );
+---------------------------------------------------------+
| CONCAT_WS(',','First name','Last Name' ) |
+---------------------------------------------------------+
| First name, Last Name |
+---------------------------------------------------------+
1 row in set (0.00 sec)


CONV(N,from_base,to_base)


Converts numbers between different number bases. Returns a string representation of the number N, converted from base from_base to to_base. Returns NULL if any argument is NULL. The argument N is interpreted as an integer, but may be specified as an integer or a string. The minimum base is 2 and the maximum base is 36. If to_base is a negative number, N is regarded as a signed number. Otherwise, N is treated as unsigned. CONV() works with 64-bit precision.
SQL> SELECT CONV('a',16,2);
+---------------------------------------------------------+
| CONV('a',16,2) |
+---------------------------------------------------------+
| 1010 |
+---------------------------------------------------------+
1 row in set (0.00 sec)


ELT(N,str1,str2,str3,...)


Returns str1 if N = 1, str2 if N = 2, and so on. Returns NULL if N is less than 1 or greater than the number of arguments. ELT() is the complement of FIELD().
SQL> SELECT ELT(1, 'ej', 'Heja', 'hej', 'foo');
+---------------------------------------------------------+
| ELT(1, 'ej', 'Heja', 'hej', 'foo') |
+---------------------------------------------------------+
| ej |
+---------------------------------------------------------+
1 row in set (0.00 sec)


EXPORT_SET(bits,on,off[,separator[,number_of_bits]])


Returns a string such that for every bit set in the value bits, you get an on string and for every bit not set in the value, you get an off string. Bits in bits are examined from right to left (from low-order to high-order bits). Strings are added to the result from left to right, separated by the separator string (the default being the comma character .,.). The number of bits examined is given by number_of_bits (defaults to 64).
SQL> SELECT EXPORT_SET(5,'Y','N',',',4);
+---------------------------------------------------------+
| EXPORT_SET(5,'Y','N',',',4) |
+---------------------------------------------------------+
| Y,N,Y,N |
+---------------------------------------------------------+
1 row in set (0.00 sec)


FIELD(str,str1,str2,str3,...)


Returns the index (position starting with 1) of str in the str1, str2, str3, ... list. Returns 0 if str is not found.
SQL> SELECT FIELD('ej', 'Hej', 'ej', 'Heja', 'hej', 'foo');
+---------------------------------------------------------+
| FIELD('ej', 'Hej', 'ej', 'Heja', 'hej', 'foo') |
+---------------------------------------------------------+
| 2 |
+---------------------------------------------------------+
1 row in set (0.00 sec)


FIND_IN_SET(str,strlist)


Returns a value in the range of 1 to N if the string str is in the string list strlist consisting of N substrings.
SQL> SELECT FIND_IN_SET('b','a,b,c,d');
+---------------------------------------------------------+
| SELECT FIND_IN_SET('b','a,b,c,d') |
+---------------------------------------------------------+
| 2 |
+---------------------------------------------------------+
1 row in set (0.00 sec)


FORMAT(X,D)


Formats the number X to a format like '#,###,###.##', rounded to D decimal places, and returns the result as a string. If D is 0, the result has no decimal point or fractional part.
SQL> SELECT FORMAT(12332.123456, 4);
+---------------------------------------------------------+
| FORMAT(12332.123456, 4) |
+---------------------------------------------------------+
| 12,332.1235 |
+---------------------------------------------------------+
1 row in set (0.00 sec)


HEX(N_or_S)


If N_or_S is a number, returns a string representation of the hexadecimal value of N, where N is a longlong (BIGINT) number. This is equivalent to CONV(N,10,16).

If N_or_S is a string, returns a hexadecimal string representation of N_or_S where each character in N_or_S is converted to two hexadecimal digits.
SQL> SELECT HEX(255);
+---------------------------------------------------------+
| HEX(255) |
+---------------------------------------------------------+
| FF |
+---------------------------------------------------------+
1 row in set (0.00 sec)

SQL
> SELECT 0x616263;
+---------------------------------------------------------+
| 0x616263 |
+---------------------------------------------------------+
| abc |
+---------------------------------------------------------+
1 row in set (0.00 sec)


INSERT(str,pos,len,newstr)


Returns the string str, with the substring beginning at position pos and len characters long replaced by the string newstr. Returns the original string if pos is not within the length of the string. Replaces the rest of the string from position pos if len is not within the length of the rest of the string. Returns NULL if any argument is NULL.
SQL> SELECT INSERT('Quadratic', 3, 4, 'What');
+---------------------------------------------------------+
| INSERT('Quadratic', 3, 4, 'What') |
+---------------------------------------------------------+
| QuWhattic |
+---------------------------------------------------------+
1 row in set (0.00 sec)


INSTR(str,substr)


Returns the position of the first occurrence of substring substr in string str. This is the same as the two-argument form of LOCATE(), except that the order of the arguments is reversed.
SQL> SELECT INSTR('foobarbar', 'bar');
+---------------------------------------------------------+
| INSTR('foobarbar', 'bar') |
+---------------------------------------------------------+
| 4 |
+---------------------------------------------------------+
1 row in set (0.00 sec)


LCASE(str)


LCASE() is a synonym for LOWER().


LEFT(str,len)


Returns the leftmost len characters from the string str, or NULL if any argument is NULL.
SQL> SELECT LEFT('foobarbar', 5);
+---------------------------------------------------------+
| LEFT('foobarbar', 5) |
+---------------------------------------------------------+
| fooba |
+---------------------------------------------------------+
1 row in set (0.00 sec)


LENGTH(str)


Returns the length of the string str, measured in bytes. A multi-byte character counts as multiple bytes. This means that for a string containing five two-byte characters, LENGTH() returns 10, whereas CHAR_LENGTH() returns 5.
SQL> SELECT LENGTH('text');
+---------------------------------------------------------+
| LENGTH('text') |
+---------------------------------------------------------+
| 4 |
+---------------------------------------------------------+
1 row in set (0.00 sec)


LOAD_FILE(file_name)


Reads the file and returns the file contents as a string. To use this function, the file must be located on the server host, you must specify the full pathname to the file, and you must have the FILE privilege. The file must be readable by all and its size less than max_allowed_packet bytes.

If the file does not exist or cannot be read because one of the preceding conditions is not satisfied, the function returns NULL.

As of SQL 5.0.19, the character_set_filesystem system variable controls interpretation of filenames that are given as literal strings.
SQL> UPDATE table_test
-> SET blob_col=LOAD_FILE('/tmp/picture')
-> WHERE id=1;
...........................................................


LOCATE(substr,str), LOCATE(substr,str,pos)


The first syntax returns the position of the first occurrence of substring substr in string str. The second syntax returns the position of the first occurrence of substring substr in string str, starting at position pos. Returns 0 if substr is not in str.
SQL> SELECT LOCATE('bar', 'foobarbar');
+---------------------------------------------------------+
| LOCATE('bar', 'foobarbar') |
+---------------------------------------------------------+
| 4 |
+---------------------------------------------------------+
1 row in set (0.00 sec)


LOWER(str)


Returns the string str with all characters changed to lowercase according to the current character set mapping.
SQL> SELECT LOWER('QUADRATICALLY');
+---------------------------------------------------------+
| LOWER('QUADRATICALLY') |
+---------------------------------------------------------+
| quadratically |
+---------------------------------------------------------+
1 row in set (0.00 sec)


LPAD(str,len,padstr)


Returns the string str, left-padded with the string padstr to a length of len characters. If str is longer than len, the return value is shortened to len characters.
SQL> SELECT LPAD('hi',4,'??');
+---------------------------------------------------------+
| LPAD('hi',4,'??') |
+---------------------------------------------------------+
| ??hi |
+---------------------------------------------------------+
1 row in set (0.00 sec)


LTRIM(str)


Returns the string str with leading space characters removed.
SQL> SELECT LTRIM('  barbar');
+---------------------------------------------------------+
| LTRIM(' barbar') |
+---------------------------------------------------------+
| barbar |
+---------------------------------------------------------+
1 row in set (0.00 sec)


MAKE_SET(bits,str1,str2,...)


Returns a set value (a string containing substrings separated by .,. characters) consisting of the strings that have the corresponding bit in bits set. str1 corresponds to bit 0, str2 to bit 1, and so on. NULL values in str1, str2, ... are not appended to the result.
SQL> SELECT MAKE_SET(1,'a','b','c');
+---------------------------------------------------------+
| MAKE_SET(1,'a','b','c') |
+---------------------------------------------------------+
| a |
+---------------------------------------------------------+
1 row in set (0.00 sec)


MID(str,pos,len)


MID(str,pos,len) is a synonym for SUBSTRING(str,pos,len).


OCT(N)


Returns a string representation of the octal value of N, where N is a longlong (BIGINT) number. This is equivalent to CONV(N,10,8). Returns NULL if N is NULL.
SQL> SELECT OCT(12);
+---------------------------------------------------------+
| OCT(12) |
+---------------------------------------------------------+
| 14 |
+---------------------------------------------------------+
1 row in set (0.00 sec)


OCTET_LENGTH(str)


OCTET_LENGTH() is a synonym for LENGTH().


ORD(str)


If the leftmost character of the string str is a multi-byte character, returns the code for that character, calculated from the numeric values of its constituent bytes using this formula:
  (1st byte code)
+ (2nd byte code . 256)
+ (3rd byte code . 2562) ...

If the leftmost character is not a multi-byte character, ORD() returns the same value as the ASCII() function.
SQL> SELECT ORD('2');
+---------------------------------------------------------+
| ORD('2') |
+---------------------------------------------------------+
| 50 |
+---------------------------------------------------------+
1 row in set (0.00 sec)


POSITION(substr IN str)


POSITION(substr IN str) is a synonym for LOCATE(substr,str).


QUOTE(str)


Quotes a string to produce a result that can be used as a properly escaped data value in an SQL statement. The string is returned enclosed by single quotes and with each instance of single quote ('), backslash ('\'), ASCII NUL, and Control-Z preceded by a backslash. If the argument is NULL, the return value is the word 'NULL' without enclosing single quotes.
SQL> SELECT QUOTE('Don\'t!');
+---------------------------------------------------------+
| QUOTE('Don\'t!') |
+---------------------------------------------------------+
| 'Don\'t!' |
+---------------------------------------------------------+
1 row in set (0.00 sec)

NOTE: Please check if your installation has any bug with this function then don't use this function.


expr REGEXP pattern


This function performs a pattern match of expr against pattern. Returns 1 if expr matches pat; otherwise it returns 0. If either expr or pat is NULL, the result is NULL. REGEXP is not case sensitive, except when used with binary strings.
SQL> SELECT 'ABCDEF' REGEXP 'A%C%%';
+---------------------------------------------------------+
| 'ABCDEF' REGEXP 'A%C%%' |
+---------------------------------------------------------+
| 0 |
+---------------------------------------------------------+
1 row in set (0.00 sec)

Another example is:
SQL> SELECT 'ABCDE' REGEXP '.*';
+---------------------------------------------------------+
| 'ABCDE' REGEXP '.*' |
+---------------------------------------------------------+
| 1 |
+---------------------------------------------------------+
1 row in set (0.00 sec)

Let's see one more example:
SQL> SELECT 'new*\n*line' REGEXP 'new\\*.\\*line';
+---------------------------------------------------------+
| 'new*\n*line' REGEXP 'new\\*.\\*line' |
+---------------------------------------------------------+
| 1 |
+---------------------------------------------------------+
1 row in set (0.00 sec)


REPEAT(str,count)


Returns a string consisting of the string str repeated count times. If count is less than 1, returns an empty string. Returns NULL if str or count are NULL.
SQL> SELECT REPEAT('SQL', 3);
+---------------------------------------------------------+
| REPEAT('SQL', 3) |
+---------------------------------------------------------+
| SQLSQLSQL |
+---------------------------------------------------------+
1 row in set (0.00 sec)


REPLACE(str,from_str,to_str)


Returns the string str with all occurrences of the string from_str replaced by the string to_str. REPLACE() performs a case-sensitive match when searching for from_str.
SQL> SELECT REPLACE('www.mysql.com', 'w', 'Ww');
+---------------------------------------------------------+
| REPLACE('www.mysql.com', 'w', 'Ww') |
+---------------------------------------------------------+
| WwWwWw.mysql.com |
+---------------------------------------------------------+
1 row in set (0.00 sec)


REVERSE(str)


Returns the string str with the order of the characters reversed.
SQL> SELECT REVERSE('abcd');
+---------------------------------------------------------+
| REVERSE('abcd') |
+---------------------------------------------------------+
| dcba |
+---------------------------------------------------------+
1 row in set (0.00 sec)


RIGHT(str,len)


Returns the rightmost len characters from the string str, or NULL if any argument is NULL.
SQL> SELECT RIGHT('foobarbar', 4);
+---------------------------------------------------------+
| RIGHT('foobarbar', 4) |
+---------------------------------------------------------+
| rbar |
+---------------------------------------------------------+
1 row in set (0.00 sec)


RPAD(str,len,padstr)


Returns the string str, right-padded with the string padstr to a length of len characters. If str is longer than len, the return value is shortened to len characters.
SQL> SELECT RPAD('hi',5,'?');
+---------------------------------------------------------+
| RPAD('hi',5,'?') |
+---------------------------------------------------------+
| hi??? |
+---------------------------------------------------------+
1 row in set (0.00 sec)


RTRIM(str)


Returns the string str with trailing space characters removed.
SQL> SELECT RTRIM('barbar   ');
+---------------------------------------------------------+
| RTRIM('barbar ') |
+---------------------------------------------------------+
| barbar |
+---------------------------------------------------------+
1 row in set (0.00 sec)


SOUNDEX(str)


Returns a soundex string from str. Two strings that sound almost the same should have identical soundex strings. A standard soundex string is four characters long, but the SOUNDEX() function returns an arbitrarily long string. You can use SUBSTRING() on the result to get a standard soundex string. All non-alphabetic characters in str are ignored. All international alphabetic characters outside the A-Z range are treated as vowels.
SQL> SELECT SOUNDEX('Hello');
+---------------------------------------------------------+
| SOUNDEX('Hello') |
+---------------------------------------------------------+
| H400 |
+---------------------------------------------------------+
1 row in set (0.00 sec)


expr1 SOUNDS LIKE expr2


This is the same as SOUNDEX(expr1) = SOUNDEX(expr2).


SPACE(N)


Returns a string consisting of N space characters.
SQL> SELECT SPACE(6);
+---------------------------------------------------------+
| SELECT SPACE(6) |
+---------------------------------------------------------+
| ' ' |
+---------------------------------------------------------+
1 row in set (0.00 sec)


STRCMP(str1, str2)


Compares two strings and returns 0 if both strings are equal, it returns -1 if the first argument is smaller than the second according to the current sort order otherwise it returns 1.
SQL> SELECT STRCMP('MOHD', 'MOHD');
+---------------------------------------------------------+
| STRCMP('MOHD', 'MOHD') |
+---------------------------------------------------------+
| 0 |
+---------------------------------------------------------+
1 row in set (0.00 sec)

Another example is:
SQL> SELECT STRCMP('AMOHD', 'MOHD');
+---------------------------------------------------------+
| STRCMP('AMOHD', 'MOHD') |
+---------------------------------------------------------+
| -1 |
+---------------------------------------------------------+
1 row in set (0.00 sec)

Let's see one more example:
SQL> SELECT STRCMP('MOHD', 'AMOHD');
+---------------------------------------------------------+
| STRCMP('MOHD', 'AMOHD') |
+---------------------------------------------------------+
| 1 |
+---------------------------------------------------------+
1 row in set (0.00 sec)


SUBSTRING(str,pos)


SUBSTRING(str FROM pos)


SUBSTRING(str,pos,len)


SUBSTRING(str FROM pos FOR len)


The forms without a len argument return a substring from string str starting at position pos. The forms with a len argument return a substring len characters long from string str, starting at position pos. The forms that use FROM are standard SQL syntax. It is also possible to use a negative value for pos. In this case, the beginning of the substring is pos characters from the end of the string, rather than the beginning. A negative value may be used for pos in any of the forms of this function.
SQL> SELECT SUBSTRING('Quadratically',5);
+---------------------------------------------------------+
| SSUBSTRING('Quadratically',5) |
+---------------------------------------------------------+
| ratically |
+---------------------------------------------------------+
1 row in set (0.00 sec)

SQL
> SELECT SUBSTRING('foobarbar' FROM 4);
+---------------------------------------------------------+
| SUBSTRING('foobarbar' FROM 4) |
+---------------------------------------------------------+
| barbar |
+---------------------------------------------------------+
1 row in set (0.00 sec)

SQL
> SELECT SUBSTRING('Quadratically',5,6);
+---------------------------------------------------------+
| SUBSTRING('Quadratically',5,6) |
+---------------------------------------------------------+
| ratica |
+---------------------------------------------------------+
1 row in set (0.00 sec)


SUBSTRING_INDEX(str,delim,count)


Returns the substring from string str before count occurrences of the delimiter delim. If count is positive, everything to the left of the final delimiter (counting from the left) is returned. If count is negative, everything to the right of the final delimiter (counting from the right) is returned. SUBSTRING_INDEX() performs a case-sensitive match when searching for delim.
SQL> SELECT SUBSTRING_INDEX('www.mysql.com', '.', 2);
+---------------------------------------------------------+
| SUBSTRING_INDEX('www.mysql.com', '.', 2) |
+---------------------------------------------------------+
| www.mysql |
+---------------------------------------------------------+
1 row in set (0.00 sec)


TRIM([{BOTH | LEADING | TRAILING} [remstr] FROM] str)


TRIM([remstr FROM] str)


Returns the string str with all remstr prefixes or suffixes removed. If none of the specifiers BOTH, LEADING, or TRAILING is given, BOTH is assumed. remstr is optional and, if not specified, spaces are removed.
SQL> SELECT TRIM('  bar   ');
+---------------------------------------------------------+
| TRIM(' bar ') |
+---------------------------------------------------------+
| bar |
+---------------------------------------------------------+
1 row in set (0.00 sec)

SQL
> SELECT TRIM(LEADING 'x' FROM 'xxxbarxxx');
+---------------------------------------------------------+
| TRIM(LEADING 'x' FROM 'xxxbarxxx') |
+---------------------------------------------------------+
| barxxx |
+---------------------------------------------------------+
1 row in set (0.00 sec)

SQL
> SELECT TRIM(BOTH 'x' FROM 'xxxbarxxx');
+---------------------------------------------------------+
| TRIM(BOTH 'x' FROM 'xxxbarxxx') |
+---------------------------------------------------------+
| bar |
+---------------------------------------------------------+
1 row in set (0.00 sec)

SQL
> SELECT TRIM(TRAILING 'xyz' FROM 'barxxyz');
+---------------------------------------------------------+
| TRIM(TRAILING 'xyz' FROM 'barxxyz') |
+---------------------------------------------------------+
| barx |
+---------------------------------------------------------+
1 row in set (0.00 sec)


UCASE(str)


UCASE() is a synonym for UPPER().


UNHEX(str)


Performs the inverse operation of HEX(str). That is, it interprets each pair of hexadecimal digits in the argument as a number and converts it to the character represented by the number. The resulting characters are returned as a binary string.
SQL> SELECT UNHEX('4D7953514C');
+---------------------------------------------------------+
| UNHEX('4D7953514C') |
+---------------------------------------------------------+
| SQL |
+---------------------------------------------------------+
1 row in set (0.00 sec)

The characters in the argument string must be legal hexadecimal digits: '0' .. '9', 'A' .. 'F', 'a' .. 'f'. If UNHEX() encounters any non-hexadecimal digits in the argument, it returns NULL.


UPPER(str)


Returns the string str with all characters changed to uppercase according to the current character set mapping.
SQL> SELECT UPPER('Allah-hus-samad');
+---------------------------------------------------------+
| UPPER('Allah-hus-samad') |
+---------------------------------------------------------+
| ALLAH-HUS-SAMAD |
+---------------------------------------------------------+
1 row in set (0.00 sec)