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 CMFCPropertyPage
  • ¥15 ad5933的I2C
  • ¥15 请问RTX4060的笔记本电脑可以训练yolov5模型吗?
  • ¥15 数学建模求思路及代码
  • ¥50 silvaco GaN HEMT有栅极场板的击穿电压仿真问题
  • ¥15 谁会P4语言啊,我想请教一下
  • ¥15 哪个tomcat中startup一直一闪而过 找不出问题
  • ¥15 这个怎么改成直流激励源给加热电阻提供5a电流呀
  • ¥50 求解vmware的网络模式问题 别拿AI回答
  • ¥24 EFS加密后,在同一台电脑解密出错,证书界面找不到对应指纹的证书,未备份证书,求在原电脑解密的方法,可行即采纳