问号显示像”????”而是来自 php 或 mysql 的波斯字符……! | 珊瑚贝

question mark show like “????” instead persian character from php or mysql…!

本问题已经有最佳答案,请猛点这里访问。


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

请告诉我解决方案

这是我的 php 代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
    <?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);

 ?>

这是我的数据库代码

1
2
3
4
5
6
7
8
9
10
11
12
    CREATE DATABASE `android_db`;

USE `android_db`;

CREATE TABLE IF NOT EXISTS `db_app` (
  `id` int(15) NOT NULL AUTO_INCREMENT,
  `movie_name` varchar(45) NOT NULL,
  `movie_image` varchar(10000) NOT NULL,
  `movie_genre` varchar(40) NOT NULL,
  PRIMARY KEY (`id`)
);

  • 浏览整个帖子 stackoverflow.com/questions/279170/utf-8-all-the-way-through 你的答案很可能在那里。
  • 还可以查看如何提问。
  • 使用 utf8mb4 作为数据库列并设置连接的字符集,如@Ray Hong 在答案中所说。请注意,如果您将 Unicode 文本存储到非 Unicode 列,MySQL 会将字符更改为 ?,您将永远丢失这些字符。不管你做了什么
  • @会计_?我收到此错误致命错误:在 null 上调用成员函数 set_charset()
  • @FarshadAsgharzadeh 那是因为对象 $mysqli 没有创建。您必须首先在代码中创建对象 $mysqli = new mysqli(“example.com”,”your_user_name”,”your_password”,”your_database_name”); 该对象称为 $con 将 $mysqli 替换为 $con
  • @会计_?谢谢,现在给我看这个”\\\?\\\?\\\?\\\?\\\?”而不是波斯字符,例如”?????”
  • @FarshadAsgharzadeh 您正在呼应 JSON。使用 json_encode( $text, JSON_UNESCAPED_UNICODE ); 看到这个问题(https://stackoverflow.com/questions/16498286/why-does-the-p??hp-json-encode-funct??ion-convert-utf-8-st??rings -到十六进制??-entit)
  • @会计_?不知该如何感谢你,你给了我莫大的恩惠,今晚我终于舒服了。 :)
  • @FarshadAsgharzadeh 不客气 :)


当字符集未设置时会发生这种情况。

连接mysql后试试,

1
2
3
4
5
6
7
8
9
/* change character set to utf8 */
if (!$mysqli->set_charset(“utf8”)) {
    printf(“Error loading character set utf8: %s\
, $mysqli->error);
    exit();
} else {
    printf(“Current character set: %s\
, $mysqli->character_set_name());
}

取自:http://php.net/manual/en/mysqli.set-charset.php


来源:https://www.codenong.com/45256336/

微信公众号
手机浏览(小程序)

Warning: get_headers(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(): Failed to enable crypto in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(https://static.shanhubei.com/qrcode/qrcode_viewid_8717.jpg): failed to open stream: operation failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57
0
分享到:
没有账号? 忘记密码?