简体   繁体   English

离子编码不适用于php post

[英]Ion encoding not working with php post

im trying to do a post to a php and save in a mysql database 我正在尝试发布到php并保存在mysql数据库中

this is the ION.with command: 这是ION.with命令:

Ion.with(this)
                            .load("http_my_page/test.php")
                            .setBodyParameter("text", "não")


                            .asString(Charset.defaultCharset())//default=UTF-8
                            .setCallback(new FutureCallback<String>() {
                                @Override
                                public void onCompleted(Exception e, String result) {

                                }


                            });

my test.php page: 我的test.php页面:

<?php
$test  = $_POST["text"]; 
$servername = ...;
$username = "..";
$password = "...";
$dbname = "...";

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

$sql = "INSERT INTO test (my_test) VALUES ('$test')";

if ($conn->query($sql) === TRUE) {
    echo "New record created successfully";
} else {
    echo "Error: " . $sql . "<br>" . $conn->error;
}

$conn->close();
?>

and my MYSQL database has a column called my_test and collation is UTF8_unicode_ci 并且我的MYSQL数据库有一个名为my_test的列,排序规则为UTF8_unicode_ci

what im specting to store: "não" 我希望存储什么:“não”

what it really store: "não" 它真正存储的是:“não”

any reason? 任何原因? since im setting all the econdings =( 因为我设置了所有的东西=(

那是一个PHP / MYSQL编码问题,与离子无关

$conn->set_charset("utf8");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM