gpt4 book ai didi

php - 得到????标记为来自 php 的响应,而不是获取泰米尔文本字符串。

转载 作者:行者123 更新时间:2023-11-30 00:33:43 25 4
gpt4 key购买 nike

我在表中有泰米尔语文本,当我使用 PHP 检索数据时,我得到了 ???作为回应。

以下是我的 PHP 代码。

    <?php 
header( 'Content-Type: text/html; charset=utf-8' );
include('connection.php');

$query = "SELECT * FROM DevotionalCollection";
$fetch=mysqli_query($con, $query ) or die(mysqli_error($con));

if (mysqli_num_rows($fetch) > 0) {
$response["data"] = array();
while ($row = mysqli_fetch_array($fetch)) {

$data = array();
$data["playlistname"] = $row["playlistname"];
$data["playlistid"] = $row["playlistid"];
$data["channelname"] = $row["channelname"];
$data["imageURL"] = $row["imageURL"];

//$response["data"] = array();
array_push($response["data"], $data);

}
header('Content-type: text/json');
$response["success"] = TRUE;
// echoing JSON response
echo json_encode($response);
}else {
// no products found
$response["success"] = FALSE;
$response["message"] = "No data found";

// echo no users JSON
echo json_encode($response);
}

?>

我得到的回应是

    {
"data": [
{
"playlistname": "?????",
"playlistid": "PLfLdj4WW-kHU4f4CGm2F9vG--ggvcy7PD",
"channelname": "Lalitha Lalli",
"imageURL": ""
},
{
"playlistname": "Colour kolam. ???? ????????. Colour muggulu. Rangoli designs",
"playlistid": "PLBYk4p11EVuoay-_RpW1x4f6N2eaE6rOO",
"channelname": "TD Kolam",
"imageURL": ""
},
{
"playlistname": "Easy Rangoli. ????????. Muggulu",
"playlistid": "PLBYk4p11EVuqkpL3gwAK2uDZfzyoLM5vW",
"channelname": "TD Kolam",
"imageURL": ""
},
{
"playlistname": "?????",
"playlistid": "PL7PWXzhNZZ0QRVUHZkouHO-Z6ONhPlejT",
"channelname": "Sumathy G",
"imageURL": ""
},
{
"playlistname": "?????",
"playlistid": "PLajt0f8unQ6XqkA_y41ypby_0_9lTf6s_",
"channelname": "Selvamani Jayabal",
"imageURL": ""
},
{
"playlistname": "???????????? ???????",
"playlistid": "PL_wM35e-Czjnzsa-97-IFOmEhOWIrJn1C",
"channelname": "A to Z Nandhini",
"imageURL": ""
},
{
"playlistname": "Chikku kolangal",
"playlistid": "PLSll0nWLklOE9i26_A8-wMHYM91ls-j_p",
"channelname": "Dr.B.Selvamuthu Krishnan",
"imageURL": ""
},
{
"playlistname": "Pink",
"playlistid": "PL-u817lYZC9GXncSo4pnnOp6EG0L-cuCk",
"channelname": "jagan sekar",
"imageURL": ""
},
{
"playlistname": "Sk",
"playlistid": "PLa7cnEZgdw5SH7ZMZENjF650Vv8CDY93L",
"channelname": "Suresh Kalai",
"imageURL": ""
},
{
"playlistname": "Popular Videos - Kolam & Puja",
"playlistid": "PL_ZkVSTePDMvkw9c6CLMCqxc7GlqD3EDU",
"channelname": "Kolam - Topic",
"imageURL": ""
},
{
"playlistname": "Rangoli Design-Kolam Design",
"playlistid": "PLFpOXrFtpgWhqGOQad3PdRZ-QUrBkOZ8l",
"channelname": "Nagu's Handwork",
"imageURL": ""
},
{
"playlistname": "Kolam",
"playlistid": "PLhSkx3hNgucQiXYpgrIZzcBSrBVr7Rr0D",
"channelname": "Jamuna Rani",
"imageURL": ""
},
{
"playlistname": "Kambi kolam",
"playlistid": "PLybpr3Tk6SmVFQ7QolQ2Pt45KbTu9IQKp",
"channelname": "Balasubramanian Krishnamurthy",
"imageURL": ""
},
{
"playlistname": "Rangoli borders. kolam border. muggulu border",
"playlistid": "PLBYk4p11EVupclfP6C4RbjHBu-9ylr1q9",
"channelname": "TD Kolam",
"imageURL": ""
},
{
"playlistname": "CHIKKU KOLAM",
"playlistid": "PLfvmbqiPYkkpuLW8psUOVz-kLCRu2EZcE",
"channelname": "thilagalakshmi sridharan",
"imageURL": ""
},
{
"playlistname": "Popular Rangoli & Kolam videos",
"playlistid": "PLxE-NIHKNadzvjuVu_EoKHHDbvunPzmJ2",
"channelname": "Rangoli - Topic",
"imageURL": ""
},
{
"playlistname": "Popular Videos - Rangoli & Peafowl",
"playlistid": "PLxE-NIHKNadxA5IAylBprcVUPYJNHaPaK",
"channelname": "Rangoli - Topic",
"imageURL": ""
},
{
"playlistname": "Popular Thai Pongal & Kolam videos",
"playlistid": "PLcIFZKKK5Ex29vy7lbWKbFstgoeG1XNCP",
"channelname": "Thai Pongal - Topic",
"imageURL": ""
},
{
"playlistname": "aanmeegam / ????????",
"playlistid": "PLCR_lidRFmjCnNhVRCRTENHZ360ySzTHH",
"channelname": "Zio Tamil",
"imageURL": ""
},
{
"playlistname": "kolangal",
"playlistid": "PL3CPcT90G7vPDD5Iw1A5FLNEMA_RXSoHY",
"channelname": "LEARNGOODALL",
"imageURL": ""
},
{
"playlistname": "108 simple Diwali kolam designs ( 4 to 9 dots ) | an easy rangoli a day to learn for Diwali decoration ideas | simple New Year rangoli",
"playlistid": "PLwHuVZQFx6IhZ-8HtC5umsnyNxFGGwfXt",
"channelname": "Sudha Balaji",
"imageURL": ""
}
],
"success": true
}

任何人都可以帮助解决这个错误。提前致谢!!!

最佳答案

  1. 检查连接中的字符集:(最好将其放在 connection.php 中)

    header( 'Content-Type: text/html; charset=utf-8' );
    include('connection.php');

    // Change character set to utf8
    mysqli_set_charset($con,"utf8");

    $query = "SELECT * FROM DevotionalCollection";
    $fetch=mysqli_query($con, $query ) or die(mysqli_error($con));

    if (mysqli_num_rows($fetch) > 0) {
    $response["data"] = array();
    while ($row = mysqli_fetch_array($fetch)) {

    $data = array();
    $data["playlistname"] = $row["playlistname"];
    $data["playlistid"] = $row["playlistid"];
    $data["channelname"] = $row["channelname"];
    $data["imageURL"] = $row["imageURL"];

    //$response["data"] = array();
    array_push($response["data"], $data);

    }
    header('Content-type: text/json');
    $response["success"] = TRUE;
    // echoing JSON response
    echo json_encode($response);
    }else {
    // no products found
    $response["success"] = FALSE;
    $response["message"] = "No data found";

    // echo no users JSON
    echo json_encode($response);
    }

    ?>
  2. 更改数据库中的字符集:

    ALTER DATABASE DBNAME CHARACTER SET utf8 COLLATE utf8_general_ci;

关于php - 得到????标记为来自 php 的响应,而不是获取泰米尔文本字符串。,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43786172/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com