在php中将windows-1256转换为utf-8或将utf-8转换为windows-1256
我在Autoplay Media Studio 8.5上用lua创建了一个程序,并将一些数据发送到MySQL数据库 我的数据库排序规则是utf8_unicode_ci,当我发送数据时,它保存在如下表中:ÓÓÓäääääÊÓÊ 当我使用AMS选择数据并显示时,没有问题 但是我想用php创建一个网页并选择数据。在这种情况下,角色仍然是这样显示的:ÓÓÓÓÓÓÓÓÊÓÊ 我在php文件中使用以下代码:在php中将windows-1256转换为utf-8或将utf-8转换为windows-1256,php,mysqli,lua,autoplay-media-studio,Php,Mysqli,Lua,Autoplay Media Studio,我在Autoplay Media Studio 8.5上用lua创建了一个程序,并将一些数据发送到MySQL数据库 我的数据库排序规则是utf8_unicode_ci,当我发送数据时,它保存在如下表中:ÓÓÓäääääÊÓÊ 当我使用AMS选择数据并显示时,没有问题 但是我想用php创建一个网页并选择数据。在这种情况下,角色仍然是这样显示的:ÓÓÓÓÓÓÓÓÊÓÊ 我在php文件中使用以下代码: <!DOCTYPE html> <html> <head>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1256" />
</head>
<body>
<?php
$db_path = "localhost";
$db_name = "mydb";
$db_user = "root";
$db_pass = "";
$conn = mysqli_connect($db_path, $db_user, $db_pass, $db_name);
if ($conn->connect_error) {die("Connection failed: " . $conn->connect_error);}
mysqli_set_charset($conn, 'cp1256');
$sql = "SELECT * FROM mytable ORDER BY id DESC LIMIT 5";
$res = mysqli_query($conn, $sql);
while($row = mysqli_fetch_assoc($res)){echo $row['col1']}
mysqli_close($conn);
?>
</body>
</html>
如果您的db是utf8,您不应该这样说mysqli_set_charset($conn,'cp1256')代码>相反,首先将值转换为utf 8谢谢您的回复。但是,请帮助我如何转换为utf8?当然,使用这个命令我无法打开链接它的php手册,为什么你能达到这个?!?!?!