how to use php mysql with arabic data

“how to use php mysql with arabic data” is question of basic mysql structure.

Basically for handling  such characters wheather they are in arabic language or in other one , we have to change the default behaviour of PHP/MYSQL .

And we can do that by enabling ‘utf-8’ charset in mysql  .

In Mysql change the default Collation “latin1_swedish_ci” to “utf8_general_ci”


Change the particular Column’s collation to “utf8_general_ci”.

Note:-There are lots of PHP Framework which by default provide the UTF-8 Support, If you just think creating your project in arabic than you can choose any standard PHP framework also like –





and so on ….

Check it also

How to get the data randomly from mysql

“How to get the data randomly from mysql ” the first question comes to mind when working with real time data.
Sometime we need the data randomly from the database .

Let say we have a app and which has some category.

App has some main categories and we wants a special category content to come randomly at a some place, like Riddle or Jumble Word or a question .So we required the data coming from mysql of that special category should be in RANDOM fashioned.

Here we will use the Rand function of mysql.

WHAT IS RAND function Generally :-

In mathematics or any other programming language the RANDOM function is available for generating the RANDOM results, in same way the mysql also has a RAND function

  • Random Data with simple select query:-

Select * from users random_table1

Data with RAND() function

In some case we wants the select query gave data randomly ,for that purpose we can use the RAND() function of MYSQL with ORDER BY 

Select  * from user ORDER BY RAND() random_table2

Again data with RAND() function

Select * from users ORDER BY RAND()


As you can see the above data after using the RAND() every time, the data we are getting is random.

Check it also

How to insert the arabic data into mysql tables

How to insert the arabic data into mysql tables is a tedious question .but mysql has supported the arabic data

In mysql we can perform operation in different languages .But for that we need to enable the utf-8,which is not enables by default.

We can achieve this by change the collation of the table.

we can change it for the whole database, or a single table or all per required  .

For changing the whole database collation , select the database than click on operation and change the collation.

Same thing can be done for a particular table ,click on table than click on operation and change the collation.

We can do this by changing the Collation in mysql table. At the time of  creating a new table or altering the existing table.

That is to say ,Collation  is set by default  on newly created tables.


We can easily change the Collation’s default value to utf8_general_ci by change option given in above image in phpmyadmin collation becomes :-two

Now you can ,insert arab language data or any other utf-8 supported character in this table of mysql.

How to use php mysql with arabic data

check for the UTF-8 Documentation

how to apply limit with union in Mysql

how to apply limit with union in Mysql query ?

We have a condition that we want to fetch some data from different tables and combined them with onion in Mysql . Which is very simple we can do this :

Query 1


Query 2


Query 3

and so on …

but in above queries if we want to apply the limit, than it will give error .

here we will discussing what we can do to achieve the results.

If  we have multiple query set than how can we use limit and union them all ?

we can do this by separating the query set with () – brackets and merge them with union in mysql , For example we have two tables :-

Table T1


Table T2


(SELECT name,city FROM T1 WHERE id < 3  LIMIT 1)
(SELECT name,city FROM T2 WHERE  ORDER BY id desc LIMIT 3);

If we do this above like this :-

SELECT name,city FROM T1 WHERE id < 3  LIMIT 1
SELECT name,city FROM T2 WHERE  ORDER BY id desc LIMIT 3

Than it will give error ……

How to get random data in Mysql

check for the documentation

How to install LAMP on ec2-instances

Here we are going to explain the Steps of installing the LAMP on ec2-instance .

  • For installing the LAMP first of all you should have the AWS account.
  • AWS offered the basic free tier for 1 year with limited space.
  • Just Go to and Click on “Sign in to the Console
  • If you have already registered user then fill the credential on below screen



  • If you don’t have the account then create a new here signup

Steps for Configuring the instance from AWS Dashboard

  • after login checkout the dashboard :-
  • login

Here we have ec2 instance Tab ,if you don’t found that on the welcome screen

than go to services->EC2 . Click on EC2 .

Then click on free tier only


  • Step 1: Choose an Amazon Machine Image (AMI)

Then select the Ubuntu 14.04 Instance for installing the LAMP

ubuntuStep 2: Choose an Instance Type – here you can choose free tier instances


Step – 3 – Configure Instance Details:-


Step – 4 Add Storage – Nothing to do ,you will get 30Gb free storage in free tier ,


Click on Add Tags – nothing is required in this section

  • Click on Configure Security Groups




  • click on Add Rule to access the instance from browser.


  • Now click on Review And Launch .


  • Click on Launch


if already have a key-pair than you can use that but i recommend to create a new one:-

1- create a new key pair from first drop down

2-key pair name (any thing you like)

3- click on Download Key Pair (keep the file safely)

4- click on Launch Instance





Click on View Launches


Here you can see info  like instance  running state,its IP address and so on.

now  we will install the LAMP on instance.

Download Useful Software for connecting to the command line

download the puttygen.exe


  • click on load and open the .pem file generated by the key pair.
  • click on generate and the .ppk file will  be downloaded which is required in ssh login
  • Click on Save Private key
  • Click ‘Yes’ on popup and name to a new .ppk file and file will be downloaded.
  • Download the putty.exe and open


1- Host Name –  IP address from AWS dashboard

2-In left side bar click on SSH than auth than browse the .ppk file which you have recently generated and click on open

3-you will get the putty security alert


click on yes next it will say login as : ubuntu (which is username)

Click yes on putty security alert and than you will be in command prompt of the instances

Here we will run commands and install LAMP  ,

Note :- in below command there will be some Y/N option will be come, choose Y to continue the operation.

LAMP Installations Command 

  • sudo su
  • apt-get update
  • apt-get install apache2
  • apt-get install mysql-server php5-mysql

it will ask for choose the server ,select apache / apache2 and ask for create  a new database password make it as you want .

  • apt-get install php5 libapache2-mod-php5 php5-mcrypt
  • service apache2 restart
  • a2enmode rewrite
  • service apache2 restart
  • apt-get install curl
  • service apache2 restart
  • cd var/www/html/
  • apt-get install php5 libapache2-mod-php5 php5-mcrypt
  • apt-get install phpmyadmin apache2-utils

Check for instance : – http://your IP Adrress /

Note :- if  phpmyadmin not worked tham

1-vim /etc/apache2/apache2.conf /// add the line to the end of the file:

2- Include /etc/phpmyadmin/apache.conf
3-/etc/init.d/apache2 restart

Congratulation you have successfully installed the LAMP on your ec2 ubuntu instance.

Run crone on AWS