编码错误PHP和Mysql为法语[重复]

时间:2022-09-22 17:25:03

This question already has an answer here:

这个问题在这里已有答案:

I have a function that adds words in my database and for some reason it's putting them in all weird.

我有一个在我的数据库中添加单词的函数,由于某种原因,它使它们变得非常奇怪。

Here is my function :

这是我的功能:

function change_team($picname, $text){
    include 'dbconnector.php';
    $conn->query("UPDATE team SET  tea_photo = '$picname', tea_text = $text WHERE tea_id = 1"); 
}

Then, I use a post form to put it in :

然后,我使用一个帖子表格将其放入:

change_team($_POST['lala'], $_POST['text']);

$_POST['text'] = éÀéÀ works when I echo it before entering it into database, but in the database it does this: Éà É

$ _POST ['text'] =éÀéÀ在我进入数据库之前回应它时起作用,但在数据库中它会这样做:ÉÉ

I've tried everything, I've put my table as uft8_general_ci but it doesn't seem like it fixes anything.

我已经尝试了所有的东西,我把我的桌子作为uft8_general_ci,但它似乎没有修复任何东西。

1 个解决方案

#1


0  

In your dbconnector.php, do:

在你的dbconnector.php中,执行:

$conn->set_charset("utf8");

After connecting and selecting database. This will set the transmission encoding to UTF-8. (The table/column/db character set is just storage encoding).

连接并选择数据库后。这会将传输编码设置为UTF-8。 (表/列/ db字符集只是存储编码)。

#1


0  

In your dbconnector.php, do:

在你的dbconnector.php中,执行:

$conn->set_charset("utf8");

After connecting and selecting database. This will set the transmission encoding to UTF-8. (The table/column/db character set is just storage encoding).

连接并选择数据库后。这会将传输编码设置为UTF-8。 (表/列/ db字符集只是存储编码)。