Hello,
I’m trying to figure out, how to get Hebrew
characters in Ionic2
html. In my connection.php
I have $con->set_charset('utf8');
, so letters appears in input fields and recorded properly in MySql
database with this connection.php
:
<?php
header("Access-Control-Allow-Origin: *");
header('Content-type: text/xhtml; charset=windows-1255');
$con = new mysqli('localhost:XXXX', 'user', 'password');
$con->set_charset('utf8');
if (!$con)
{
echo 'Not Connected To Server';
}
if (!mysqli_select_db ($con, 'mydb'))
{
echo 'Database Not Selected';
}
?>
But in several places, seems like, when I’m trying to get it from list, for example below home.ts
this.function();
http
request, it appears this way:
function() {
var headers = new Headers();
headers.append('Content-Type', 'application/x-www-form-urlencoded');
let options = new RequestOptions({ headers: headers });
let postParams = '&user=' + this.user;
this.http.post(this.phpPath + "select.php", (postParams), options)
.subscribe(data => {
var nmb = (data.text().split(".").length);
let x = data.text().split(".");
for (var i = 0; i < nmb; i++) {
var c = x[i];
this.list.push({ id: i, name: this.s + c }, );
}
}, error => {
console.log(error);
});
}
particularselect.php
uses connection.php
:
<?php
require 'connection.php';
$user = mysqli_real_escape_string($con, $_POST["user"]);
$sql = "SELECT name FROM tab where user='".$user."'";
$result = mysqli_query($con, $sql);
if (mysqli_num_rows($result) > 0) {
while($row = mysqli_fetch_assoc($result)) {
echo $row["name"].'.';
}
} else {
echo "0 results";
}
mysqli_close($con);
?>
I’ve tried to add <meta charset="UTF-8">
to home.html
, but index.html
already contains it. And also I’ve tried to save home.html
with notepad encoded with UTF-8
, but nothing helps