用脚本搜索php代码中的波斯语字符

用脚本搜索php代码中的波斯语字符,php,internet-explorer,character-encoding,Php,Internet Explorer,Character Encoding,我想在数据库中搜索字符串,我的代码在Firefox和Chrome中正确执行,但在IE中,数据的值是问号,不能正常工作。 我搜索波斯语字符串,在英语中它是正确的。 当我写 echo $data; 在IE中,它会为每个字符返回一个问号,例如我写的“علي”,它会返回 我的代码是: <?php include ("include/dbconnect_user.php"); ?> <script> function search(str) { if (w

我想在数据库中搜索字符串,我的代码在Firefox和Chrome中正确执行,但在IE中,数据的值是问号,不能正常工作。 我搜索波斯语字符串,在英语中它是正确的。 当我写

echo $data;
在IE中,它会为每个字符返回一个问号,例如我写的“علي”,它会返回

我的代码是:

<?php
    include ("include/dbconnect_user.php");
?>
<script>
function search(str)
{
        if (window.XMLHttpRequest){
            xmlhttp=new XMLHttpRequest();
        }else{
            xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
        xmlhttp.onreadystatechange=function()
        {
        if (xmlhttp.readyState==4 && xmlhttp.status==200)
            {
            document.getElementById("txtSearch").innerHTML=xmlhttp.responseText;
            }
        }
        xmlhttp.open("GET","users.php?data="+str,true);
        xmlhttp.send(); 
}
</script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<body>
<div id='img' align='center'></div>

<?php                   
if(isset($data)){
    $alternate = "2"; 
    echo "<table id='maintable' class='sortcompletecallback-applyZebra'>";
    foreach($disp_cols as $col) {

        if(!in_array($col, array("home", "work", "mobile", "select", "edit", "homepage", "details"))) {
          echo "<th>".ucfmsg(strtoupper($col))."</th>";
        } elseif(in_array($col, array("home", "work", "mobile"))) {
          echo "<th>".ucfmsg("PHONE_".strtoupper($col))."</th>";
        }
    }
    $sql="select * from `addressbook` where ";
    $sql.= " `lastname`   LIKE '%$data%'
                OR `firstname`  LIKE '%$data%'
                OR `work` like '%$data%'
                OR `email`      LIKE '%$data%'
                OR `unit`     LIKE '%$data%'
                OR `post`      LIKE '%$data%' ";

        $sql=mysql_query($sql);
        while($query=mysql_fetch_array($sql)){
            $firstname=$query['firstname'];
            $lastname=$query['lastname'];
            $mail=$query['email'];
            $work=$query['work'];
            $post=$query['post'];
            $unit=$query['unit'];
            $color = ($alternate++ % 2) ? "odd" : "";
            echo "<tr class='".$color."' name='entry'>";
            echo    "
                    <td style='padding-right:5px;'>$lastname $firstname</td>
                    <td align='left' style='padding-right:5px;'>$mail</td>
                    <td align='left'  style='padding-left:5px;'>$work</td>
                    <td align='center'  style='padding-left:5px;'>$unit</td>
                    <td align='left'  style='padding-left:5px;'>$post</td></tr>";
        }
    echo    "</table>";         

}else{
 include ("include/header.inc_user.php");

echo    "<div id='search-az'>
    <div style='font-size: 13px;'> جستجو 
    <input type='text'  name='search' tabindex='0' onkeyup='search(this.value)' autofocus />
            </div>
            </div><br />
            <hr />";

}
?>

    <div id='txtSearch'><div id='newdivSearchID'>

    </div>
    </div>
试着替换

 xmlhttp.open("GET","users.php?data="+str,true);
与:


是的,Tanx非常感谢你的帮助
 xmlhttp.open("GET","users.php?data="+encodeURIComponent(str),true);