我觉得这应该是一个简单的解决方法,但答案却无济于事。香港专业教育学院试图谷歌搜索,并在这里搜索...无济于事。

我的数据库中存储了很长的文字。
排序规则为latin1_swedish_ci“
当我在数据库中看到它时,它存储正确。例如:

     string= Sally was walking one day and saw Tom.  Tom said "Hi, Sally!" Sally's response was "Hi, Tom."


每个“或”在黑色菱形上显示为白色问号。

我想要

     $result=mysqli_query($db,"SELECT string FROM Table WHERE 1")
     while($row = mysqli_fetch_assoc($result)){
          echo $row['string'];
     }


并显示所有字符。
有人可以帮忙吗?

最佳答案

您可以使用此示例修复您的示例。

SQL:

    CREATE TABLE `test` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `string` longtext,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=latin1;

INSERT INTO `test` VALUES ('1', 'Sally was walking one day and saw Tom.  Tom said \"Hi, Sally!\" Sally\'s response was \"Hi, Tom.\"');

PHP:

$query = "SELECT id, string FROM test WHERE id = 1";

if ($result = mysqli_query($link, $query)) {

    while ($row = mysqli_fetch_assoc($result)) {
        echo $row['string'];
    }

    mysqli_free_result($result);
}

mysqli_close($link);

10-06 05:42