Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/68.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
问号显示像“什么?”&引用;而不是来自php或mysql的波斯语字符。。。!_Php_Mysql - Fatal编程技术网

问号显示像“什么?”&引用;而不是来自php或mysql的波斯语字符。。。!

问号显示像“什么?”&引用;而不是来自php或mysql的波斯语字符。。。!,php,mysql,Php,Mysql,对不起。。。!我的英语不是很好! 直到上周我还在使用“www.000webhost.com”网络主机,我没有任何问题!!! 但今天我买了一台新服务器,像以前一样使用旧文件。。。 我不知道问题是来自php文件还是数据库 请告诉我解决办法 这是我的php代码 <?php //Creating a connection $con = mysqli_connect("___","___","___","___"); if (mysqli_connect_errn

对不起。。。!我的英语不是很好! 直到上周我还在使用“www.000webhost.com”网络主机,我没有任何问题!!! 但今天我买了一台新服务器,像以前一样使用旧文件。。。 我不知道问题是来自php文件还是数据库

请告诉我解决办法

这是我的php代码

    <?php 
    //Creating a connection
    $con = mysqli_connect("___","___","___","___");

    if (mysqli_connect_errno())
    {
       echo "Failed to connect to MySQL: " . mysqli_connect_error();
    }
    /*Get the id of the last visible item in the RecyclerView from the request and store it in a variable. For            the first request id will be zero.*/  
    $id = $_GET["id"];

    $sql= "Select * from db_app where id between ($id+1) and ($id+10)";

    $result = mysqli_query($con ,$sql);

    while ($row = mysqli_fetch_assoc($result)) {

        $array[] = $row;

    }
    header('Content-Type:Application/json');

    echo json_encode($array);

    mysqli_free_result($result);

    mysqli_close($con);

 ?>

未设置角色集时会发生这种情况

在mysql连接之后尝试

/* change character set to utf8 */
if (!$mysqli->set_charset("utf8")) {
    printf("Error loading character set utf8: %s\n", $mysqli->error);
    exit();
} else {
    printf("Current character set: %s\n", $mysqli->character_set_name());
}

摘自:

通读这篇文章,你的答案很可能就在那里。同时也要通读一遍。对数据库列使用
utf8mb4
,并设置连接的字符集,如@Ray Hong在回答中所说。注意,如果您将Unicode文本存储到非Unicode列,MySQL将把字符更改为
,您将永远丢失字符。不管你做什么did@Accountant_م我得到这个错误致命错误:调用上的成员函数set_charset()null@FarshadAsgharzadeh这是因为没有创建对象
$mysqli
。您必须首先创建对象
$mysqli=newmysqli(“example.com”、“your_user_name”、“your_password”、“your_database_name”)
在代码中,对象称为
$con
$con
替换
$mysqli
/* change character set to utf8 */
if (!$mysqli->set_charset("utf8")) {
    printf("Error loading character set utf8: %s\n", $mysqli->error);
    exit();
} else {
    printf("Current character set: %s\n", $mysqli->character_set_name());
}