I have this insertion PHP code :
<?PHP
require("config.inc.php");
if (!empty($_POST)) {
$query = "INSERT INTO projects ( project_author, project_title, project_spec, project_links, project_desc,created_at ) VALUES ( :user, :title, :spec, :links, :desc, NOW() ) ";
$query_params = array(
':user' => $_POST['author'],
':title' => $_POST['title'],
':spec' => $_POST['spec'],
':links' => $_POST['links'],
':desc' => $_POST['desc'],
);
try {
$stmt = $db->prepare($query);
$result = $stmt->execute($query_params);
}
catch (PDOException $ex) {
$response["success"] = 0;
$response["message"] = "Database Error. Couldn't add post!";
die(json_encode($ex));
}
$response["success"] = 1;
$response["message"] = "Post Successfully Added!";
echo json_encode($response);
}else{
echo 'omar almrsomi';
}
?>
The retrieving PHP code from MySQL is:
<?php
$mysql_db_hostname = "com";
$mysql_db_user = "xxxxx";
$mysql_db_password = "xxxxxxxxxx";
$mysql_db_database = "xxxxxxxxx";
$con = @mysqli_connect($mysql_db_hostname, $mysql_db_user, $mysql_db_password,
$mysql_db_database);
if (!$con) {
trigger_error('Could not connect to MySQL: ' . mysqli_connect_error());
}
$var = array();
$sql = "SELECT * FROM projects";
$result = mysqli_query($con, $sql);
while($obj = mysqli_fetch_object($result)) {
$var[] = $obj;
}
echo '{"projects":'.json_encode($var).'}';
?>
Problem:
The insertion and retrieving from MySQL gave ????????????? sign.
Note:
Inserted text in Arabic.
Question:
How to insert Arabic (Unicode) to MySQL?
Thanks in advance