I am using retrofit2. I want to make a post method. English is stored properly, but when I try to store Hindi/Bengali It doesn't show the real data in the database.
ID - 4 and 5 were created from a SQL command.
ID - 6 was stored by POST method from Android.
ID - 7 was stored by the same method but it didn't have any problem.
Below the code is for server side API
<?php
$servername = "";
$username = "";
$password = "";
$dbname = "";
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$text = $_POST['text'];
$options = $_POST['options'];
$query = "INSERT INTO questions (text, options) VALUES ('$text', '$options')";
if ($conn->query($query) === TRUE) {
echo "Question added successfully";
} else {
echo "Error: " . $query . "<br>" . $conn->error;
}
}
$conn->close();
?>
This is my android API Interface:
import retrofit2.Call;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.POST;
public interface ApiService {
@FormUrlEncoded
@POST("add_question.php")
Call<Void> addQuestion(
@Field("text") String text,
@Field("options") String options
);
}
Help me solve the problem and write me the solution code if it is needed. I just need the word what I input in my edittext and want to see it in my phpmyadmin exactly like that...