Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/61.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 从Web服务向mysql数据库插入数据时瑞典字符编码失败_Php_Mysql_Utf 8_Pdo - Fatal编程技术网

Php 从Web服务向mysql数据库插入数据时瑞典字符编码失败

Php 从Web服务向mysql数据库插入数据时瑞典字符编码失败,php,mysql,utf-8,pdo,Php,Mysql,Utf 8,Pdo,我试图从网络服务中插入瑞典字符, 我的代码是这样的 Header("Content-Type: text/html; charset=UTF-8"); $xml = new XMLReader(); $xml->open("http://ws.aldoc.eu/ws/mekafrance/menu.alx"); $j= 4; $id = 6; $idp = 6; while($xml->read()){ if ($xml->nod

我试图从网络服务中插入瑞典字符, 我的代码是这样的

Header("Content-Type: text/html; charset=UTF-8");
$xml = new XMLReader();
    $xml->open("http://ws.aldoc.eu/ws/mekafrance/menu.alx");
    $j= 4;
    $id = 6;
    $idp = 6;
    while($xml->read()){
    if ($xml->nodeType == XMLREADER::ELEMENT && $xml->localName == "Menuitem")
    {
        $product = $xml->expand();
        $product = new SimpleXMLElement('<Menuitem>'.$xml->readInnerXML().'</Menuitem>');
        $menucode = $product->menucode;
$stmt = $dbh->prepare("insert into `ps_category_lang`(`name`) values ( :name)");        
    $stmt->bindParam(':name', $name);   
    $name =  mb_convert_encoding((string)$product->menu,"utf-8");

    $stmt->execute();
            }
           }
标题(“内容类型:text/html;字符集=UTF-8”);
$xml=newXMLReader();
$xml->open(“http://ws.aldoc.eu/ws/mekafrance/menu.alx");
$j=4;
$id=6;
$idp=6;
而($xml->read()){
如果($xml->nodeType==XMLREADER::ELEMENT&&$xml->localName==“Menuitem”)
{
$product=$xml->expand();
$product=新的SimpleXMLElement('.$xml->readInnerXML();
$menucode=$product->menucode;
$stmt=$dbh->prepare(“插入到`ps_category_lang`(`name`)值(`name'));
$stmt->bindParam(':name',$name);
$name=mb_convert_编码((字符串)$product->menu,“utf-8”);
$stmt->execute();
}
}
当我查看名称字段时,它会显示类似于“AC/Klimatanl÷gg”的内容

字段编码是utf8\U general\U ci,数据库也是。
该文件采用utf-8编码,我也将标题设置为utf。

如果您使用记事本++打开menu.alx,并将整个xml文件的编码设置为utf-8,我想您的问题就会消失。

menu.alx是Web服务的url不是我的。我通过参考prestashop配置文件require('config/config.inc.php'),解决了这个问题;每当你看到
Ã
出现在文本中,你就会遇到字符集编码问题。渲染管道中的某个地方有东西在损坏文本。