Retrieve Arabic Data From Database

arabic text showing question marks php
mysql_set_charset
display unicode characters in php
display arabic text in php

I have a simple search using PHP and MySQL

it works perfectly for English text, but for Arabic text it will not retrieve any data without any Error

while executing the same MySQL query on Database "PhpMyAdmin" works perfectly

Result.PHP


<?php
if(!isset($_POST["search"])){$_POST["search"]="";}
echo $search=$_POST["search"];  
$servername = "localhost";
$username = "aramtryf_laravel";
$password = "Reha@2015";
$dbname = "aramtryf_laravel";

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}
$sSQL= 'SET CHARACTER SET utf8'; 

mysqli_query($conn,$sSQL); 

$sql = "  SELECT * FROM oldorgs WHERE org_name like '%$search%'  ";
$result = $conn->query($sql);

if ($result->num_rows > 0) {
    // output data of each row
    while($row = $result->fetch_assoc()) {



echo    "<tr>
      <th scope='row'>".$row["org_name"]."</th>
      <td>".$row["gov"]."</td>
      <td>".$row["sector"]."</td>
      <td>".$row["email"]."</td>

    </tr>";


    }
} 
$conn->close();
?> 

instead of

$sSQL= 'SET CHARACTER SET utf8'; 

mysqli_query($conn,$sSQL); 

try

mysqli_set_charset($conn,"utf8");

display arabic data from mysql database, i have some arabic text that needs to get stored in database and then display it at user end. To store it in database i changed the collation to  Just like any other language. It's easier when you set the MySQL's database's codepage. This explains it all: How to Store Arabic or Hebrew Characters in a MySQL Database More: * How to make Mysql database to support Arabic Language?

Try adding

mysql_query("SET NAMES 'utf8'");
mysql_query("SET CHARACTER SET 'utf8'");

after the you connect to mysql.

or you can use this one.

mysqli_set_charset($conn, "utf8");

How to retrieve or update arabic data from mysql database by php , Just like any other language. It's easier when you set the MySQL's database's codepage. This explains it all: How to Store Arabic or Hebrew Characters in a  HowTo: Read,Search, and Retrieve data from files with PHP (Arabic) PHP Tutorials: jQuery: Get Data from MySQL Database without Refreshing 16:50. Save and Retrieve Data in Text Files Using

Mysql has a partial implementation of UTF-8. So I'd suggest you stick to the HTML UTF-8 for example:

<meta charset="utf-8">

Or you can use utf8mb4 to fully support UTF-8 in mysql.

How to retrieve data from mysql in arabic and show it in PHP web , Everything on the Web supports Unicode and UTF; UTF-8 is standard-de-facto. Perso-Arabic script and corresponding Unicode code point  About Retrieve data SQL Server is the product of Microsoft which provides the facility to insert, update, delete and retrieve data from database table so if you need to see the records of the table or a specific row or column then you can also do it.

It's definitely works : Your html page set to meta data UTF-8

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

OR In Mysql try this

$connect = mysql_connect("localhost","root","");
mysql_select_db("arabicd", $connect);
mysql_query("SET NAMES utf8");

A Guide to UTF-8 Encoding in PHP and MySQL, How to migrate data from a MySQL database previously encoded in latin1 to instead use a UTF-8 encoding. PHP UTF-8 Encoding – modifications to your php.​ini  Thanks for contributing an answer to Stack Overflow! Please be sure to answer the question.Provide details and share your research! But avoid …. Asking for help, clarification, or responding to other answers.

Arabic language in my sql show as ?????? why and how to solve , Hi guys are there are any way to display Arabic language in MySQL the 3. the charset of the connection between the client and the database server. want and must all be talking the same charset when they get/push data. I want to retrieve data from database on basis of language selected. For example if user selects Arabic language then all dropdown values should be populated in Arabic language. This thread is locked.

Oracle connection to retrieve or insert Arabic values from database , From the oracle database, when you try to fetch data, normally you will get the character encoding will be the encoding type of the client installed in the system  Retrieve table data and save that data into same table in C# Searching and displaying data based on ID in excel on button click in c# how to retrieve the data from database in asp.net on submit btn click

Solved: Insert Arabic Characters into mysql Database, Solved: I'm trying to insert Arabic character from coldfuin 7 into mysql 4.1 DB the DB admin and try to inset Arabic it works fine but when I use coldfusion I get ? database, but in the java application i can only view arabic data but not write. If the correct data-type is not used or the data is not preceded with an N, SQL Server will save the data to the table as ‘?’ or another garbled character. The following scripts demonstrate saving and retrieving multi-lingual data to and from SQL Server. I have used Google Translate to get the characters of other languages. I left out far

Comments
  • have you tried, mysqli_set_charset($conn,"utf8"); instead of that query.
  • Hi @yasoh it Worked perfectly Thanks How Can I make ur answer as as correct answer
  • i've added my comment as answer now if you want to vote for it.
  • Hi @Mawia I also added ur suggestion but with same issue
  • @Rebaz: If you happy with my answer can you please up vote then. please
  • Hi , Thanks for support, I tried @yasoh s answer ,it worked perfectly
  • Ok as you wish. (y) Keep programming :)