gpt4 book ai didi

jquery - 如何从sql中设置unicode数据?

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

如何设置 unicode utf-8 到这个 scipt 群发邮件发件人

HTML:

<form action="sendemail.php" method="post">
<label>Subject of email:</label><br><input type="text" name="subject" id="subject"/><br>
<label>Body of email:</label><br><textarea name="body" id="body" rows="10" cols="70"></textarea><br>
<input type="submit" name=submit value="Submit"/>
</form>

PHP:

<?php

$user = "user_name";
$password = "password";
$host = "host_name";
$dbase = "database_name";
$table = "table_name";

$from= 'email_address';

$subject= $_POST['subject'];
$body= $_POST['body'];

$dbc= mysqli_connect($host,$user,$password, $dbase)
or die("Unable to select database");

$query= "SELECT * FROM $table";
$result= mysqli_query ($dbc, $query)
or die ('Error querying database.');

while ($row = mysqli_fetch_array($result)) {
$first_name= $row['first_name'];
$last_name= $row['last_name'];
$email= $row['email'];
$msg= "Dear $first_name $last_name,\n$body";
mail($email, $subject, $msg, 'From:' . $from);
echo 'Email sent to: ' . $to. '<br>';
}
mysqli_close($dbc);
?>

$last_name 是 ėkovič,显示邮件信件 - ?kovi?

附:设置character_set_client='utf8'

设置 collat​​ion_connection='utf8_general_ci' 不起作用。

最佳答案

您需要设置字符编码才能获得相同的结果

set character_set_client='utf8'

set collation_connection='utf8_general_ci'

参见Here有关应用程序的字符集和排序规则的更多信息

您还应该看到这篇文章 How to display Unicode data with PHP

关于jquery - 如何从sql中设置unicode数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24089594/

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