【问题标题】:Issue while fetching data from database using web-services使用 Web 服务从数据库中获取数据时出现问题
【发布时间】:2012-08-13 21:19:29
【问题描述】:

我创建了 Web 服务来从古吉拉特语(其他语言)的数据库中获取数据。

当我在浏览器中访问 Web 服务的 URL 时,我得到“????????????”而不是真实数据。

请帮我摆脱它。

谢谢

【问题讨论】:

  • 取决于网站使用什么编码,浏览器使用什么编码
  • bdia question rahul,我赞成

标签: php web-services rest


【解决方案1】:

你必须设置编码

ini_set('default_charset', 'utf-8');

在您的网络服务 php 文件中。

【讨论】:

【解决方案2】:

Rahul bhai,先尝试运行这个脚本:

<?php
$mysqli = new mysqli("localhost", "my_user", "my_password", "test");

/* check connection */
if (mysqli_connect_errno()) {
    printf("Connect failed: %s\n", mysqli_connect_error());
    exit();
}

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

$mysqli->close();
?

如果您可以修改网络服务,请尝试将字符集设置为utf-8,如上所示,或浏览stackoverflow以查找类似问题,其中用户要求设置字符集等

【讨论】:

  • Rahul bhai plz 'upvote'/'mark as answer' 如果这能解决您的问题
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-09-23
  • 2021-11-26
  • 2023-03-21
  • 1970-01-01
相关资源
最近更新 更多