how to insert arabic text in mysql

Step-1 Create database table

CREATE TABLE <code>language_messages</code> (
  <code>lang_id</code> int(11) NOT NULL auto_increment,
  <code>en</code> varchar(500) NOT NULL,
  <code>ar</code> varchar(500) NOT NULL,
  PRIMARY KEY  (<code>lang_id</code>)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=8 ;

INSERT INTO <code>language_messages</code> VALUES (1, 'About Us', 'من نحن');
INSERT INTO <code>language_messages</code> VALUES (2, 'Contact Us', ' تواصل معنا ');
INSERT INTO <code>language_messages</code> VALUES (5, '', 'శ్రీనివాస్ తామాడా');

Step-2 create connection

$conn=mysql_connect(HOST,DB_USER,DB_PASS) or die(mysql_error());
$db=mysql_select_db(DB_NAME,$conn) or die(mysql_error());
mysql_query("set character_set_server='utf8'");
mysql_query("set names 'utf8'");

Step-3 View output in HTML page

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!--<html dir="rtl" lang="ar" xml:lang="ar" xmlns="http://www.w3.org/1999/xhtml">-->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
</head>

<body>

<?php $sql = "select * from language_messages"; $res = mysql_query($sql) or die(mysql_error()); while($row = mysql_fetch_array($res)) { echo" ". $row['en']; echo" ". $row['ar']; } ?>
</body>
</html>

Disable “Install the WooThemes updater plugin to get updates”

Here’s a single line code which allows you to get rid of annoying WooCommerce admin notices i.e “Install the WooThemes updater plugin to get updates for your WooThemes plugins”.

All you need to do is copy the following code snippet and paste it inside your functions.php file located inside your themes directory.

remove_action('admin_notices', 'woothemes_updater_notice');

Display Previous Next Post link at Bottom of Post in WordPress

Displaying previous and next post link at the bottom of the post will make the user to click on that link and check other posts. It also increases the traffic rate. Here is the tutorial for how to display previous next post link at Bottom of Post in wordpress.
This is done by simple coding to be placed in functions.php and style.css and not by installing plugins
WordPress Admin Panel -> Appearance -> Editor -> functions.php
Place the following code inside functions.php file

functions.php

function next_prev_link($link) {
if(is_single())
{
$prev_post = get_previous_post();
if (!empty( $prev_post ))
{
$link .= '<a href="'.get_permalink($prev_post->ID).'" class="prev"><< '.$prev_post->post_title.'</a>';
}

$next_post = get_next_post();
if (!empty( $next_post ))
{
$link .= '<a href="'.get_permalink( $next_post->ID ).'" class="next">'.$next_post->post_title.' >></a>';
}
}
return $link;
}
add_filter('the_content', 'next_prev_link');

WordPress Admin Panel -> Appearance -> Editor -> style.css
Place the following code inside style.css file
style.css

.prev, .next
{
display: block;
}
.prev
{
float: left;
}
.next
{
float: right;
}

How to Create Widget in WordPress using PHP Code

Widget in wordpress will be more helpful for non-developer, widget can be create easily with simple steps. Widgets are the important advantage in wordpress, . Here is the tutorial for how to create widget in wordpress using php code.
function wearecoders_plugin() – this function will create the widget name as “wearecoders Widget”
function form() – this function will be used to display the content to Admin area

function widget() – this function will be used to display the content to visitor area
Add the below coding into your functions.php

class wearecoders_plugin extends WP_Widget
{
function wearecoders_plugin()
{
parent::WP_Widget(false, $name = __('Wearecoders Widget', 'wearecoders_plugin') );
}
function form()
{
echo "<b>This is sample widget</b>";
}
function widget()
{
echo "<b>This is sample widget</b>";
}
}
add_action('widgets_init', create_function('', 'return register_widget("wearecoders_plugin");'));

Security tips to protect your website from hackers

Now a days this is a common issue with the websites is that they are getting hacked or malware affected. Everyday millions of website are getting hacked and blocked by Google. In many cases the hacker or malware add malicious codes in your HTML or PHP files, edit your .htaccess file, add or edit your MySql database, some time even they delete all records from database tables by using truncate table command. Also they uploaded files to web server. How is it possible to upload files, editing database or changing files without knowing the passwords? Yes, this is possible for hackers, because the they are are the best.
The following are few of my findings to stop hacking, but the hackers can say better how to protect them..

Protect through .htaccess file
.htaccess file contains the configuration statements/ commands to customize the Apache Web server as per user requirement.
Disable php global
Some web server allow user to change php settings through .htaccess file, if your host provides this option then you can disable php global through .htaccess file. Write down the following code in the first line of your .htaccess file. If you see 500 internal sever error after adding the code, then remove this code from your .htaccess file.

php_flag register_globals off

Turn off Server Signature
It is better to turn off your server information, so the hacker will get less information about your server.

Disable Directory Listing
This is a best practices to disable your directory listing. If your fancy indexing is enable then it should also disable. Fancy indexing is used to display file size, type modified date etc.

Opptions -Indexes
IndexOptions -FancyIndexing

Deny access to Directories
You can create a separate .htaccess file and upload it to those folders which you want deny access.

Order Deny, Allow
Deny from all

Disallow the access of any file
You can protect your config files and other important files by adding the following in your htaccess file.

<files .htaccess>
order allow,deny
deny from all
</files>

<files php.ini>
order allow,deny
deny from all
</files>

<files config.php>
order allow,deny
deny from all
</files>

Upload Directory
If you give option to your to upload files then there will be more possibility, your site will be hacked or affected by malware. In that case create a .htaccess file save it in your user uploaded directory.

deny from all
<Files ~ "^\w+\.(gif|jpe?g|png)$">
order deny,allow
allow from all
</Files>

Preventing hotlinking

RewriteRule \.(gif|jpg|js|css)$ - [F]

URL Rewrite or SEO Friendly URL
This is a best practices to use SEO friendly URL. If your page url is

 http://wwww.wearecoders.net/test.php?id=6 

Then the hacker can easily enter into your database through id, so you can change your URL to something like this

http://wwww.domain.com/test/6/
or
http://wwww.domain.com/test-6/

So your final .htaccess file will look something like this

php_flag register_globals off 
RewriteEngine on
RewriteBase /
ServerSignature Off
RewriteRule \.(gif|jpg|png|js|css|php)$ - [F]
Opptions -Indexes
IndexOptions -FancyIndexing

/* URL Rewrite code goes here */

<files .htaccess>
order allow,deny
deny from all
</files>

More .htaccess Examples

Deny/Allow Certain IP Addresses
Block an IP Address

#Deny List

order allow,deny
deny from 198.198.198.198 #specify a specific address
deny from 198.198.198.198/30 #specify a subnet range
deny from 198.198.* #specify an IP address wildcard
allow from all

Allow an IP address

#Allow List

order allow,deny
allow from 198.198.198.198 #specify a specific address
allow from 198.198.198.198/30 #specify a subnet range
allow from 198.198.* #specify an IP address wildcard 
deny from all

Disable directory browsing
For security reason it is always better to disable directory browsing so that people won’t know what files you have. The following code will do so.

Options All -Indexes

Adding MIME Types
If your server is not set up to deliver certain file like MP3 or SWF properly then you can add the MIME type for those through .htaccess.

AddType application/x-shockwave-flash swf

Change your default directory page
Through DirectoryIndex you can change your default landing page of your website. The default landing pages are index.html, index.php, default.php etc. But if want to change it to some other page then please use the following code.

DirectoryIndex filename.html

Protect .htaccess files

<files .htaccess>
order allow,deny
deny from all
</files>

Protect php.ini file

<files php.ini>
order allow,deny
deny from all
</files>