douhan1860 2011-02-22 17:43
浏览 89
已采纳

使用PHP将希腊语/土耳其语/波兰语字母插入mysql数据库时遇到问题

I'm reading the word Αθήνα from a table which is utf8_unicode_ci encoded and can display it without problem on a utf-8 HTML page. i scrape some more greek and also this is shown correctly. now i want to write the information back to the database in another utf8 table. but the results are this: ????? or Î?θήνα(when i use utf8_encode() on it). I also set

$this -> mysqli->set_charset("utf8");

What am I doing wrong, this is driving me crazy? Any help appreciated thx a lot!

its basically

read out:

    $result = $this -> mysqli->query("SELECT * FROM `A` WHERE `country_code` = 'GRC'");
    /* Tell browser to use UTF-8 */
    header("Content-Type: text/html; charset=utf-8");
    /* The actual scrape loop, done for every found entry in the urls table*/
    while ($row = $result->fetch_array(MYSQLI_ASSOC)) {
       $this -> urls_array[] = $row;
    }

write back:

$deal=$this -> urls_array[$key];
$this -> mysqli->query("INSERT INTO `B` (`city_name`,`title`....) 
        VALUES (
            '{$deal["city_name"]}',
            '{$title}'
            )
            ");
  • 写回答

1条回答 默认 最新

  • dougai2427 2011-02-22 17:49
    关注

    Try executing "SET NAMES utf8" before inserting anything. There's a modern way of doing it but nonetheless this should work.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 matlab实现基于主成分变换的图像融合。
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制
  • ¥20 usb设备兼容性问题
  • ¥15 错误(10048): “调用exui内部功能”库命令的参数“参数4”不能接受空数据。怎么解决啊