0

I'm trying to develop a PHP script to insert Arabic language in mysql db, but the issue when I insert the data thru PHP code I got a unknown language, as show below.

Snapshot of unknown language:

image

as I'm using the below PHP script to insert the data .

<html>
<head>
<title>Insert test</title>
<form action="insert_data_script.php" method="post">
<input type="text" name="text" value="name">
<input type="submit" value="submit">
</form>
</head>
</html>

as the insert_data_script.php will include the below ;

<?php

$servername = "localhost";
$username = "abrazaqc_cyclist";
$password = "xxxxxx";

$conn = mysqli_connect($servername, $username, $password);

if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}

$sql ="INSERT INTO  `abrazaqc_test`.`insert` (
`idinsert` ,
`info`
 )
VALUES (
NULL ,  '" . $_POST["text"] ."'
)";



if (mysqli_query($conn, $sql)) {
echo "New record created successfully";
} else {
echo "Error: " . $sql . "<br>" . mysqli_error($conn);
}

mysqli_close($conn);
?>

Notes: snapshot from table:

table

  • I have tried everything, but I can't solve the issue .
  • I hope someone can help me to solve the issue .
ashiquzzaman33
  • 5,781
  • 5
  • 31
  • 42

1 Answers1

0

Try to specify you are using UTF-8 when you connect to mySql with PHP:

Add the following code when you connect to the DB:

mysql_query("SET NAMES 'utf8'"); 
mysql_query('SET CHARACTER SET utf8'); 
Thomas
  • 677
  • 6
  • 10