<?php
echo "中文乱码";
?>
这样是不是乱码,如果是的话,打开apache的httpd.conf文件,改AddDefaultCharset GB2312
重启web服务器

解决方案 »

  1.   

    http://www.eaoo.com/design/list.asp?classid=2&Nclassid=9
      

  2.   

    我反程序的层次改了一下,就是一行行的调整顺序,现在可以了,希望研究PHP的人关注这个问题.
    调整后的代码为:
    <?
    require('login_info.php');
    function getpath($dtime)
    {
        $dds=split(" ",$dtime);
        $dd=split("-",$dds[0]);
        return "/".$dd[0]."/".$dd[1];
    }
    //----模板文件及要创建的文件-------------
    $mod_file = $base_dir.$art_dir."/mod/mod/mod.htm";
    $make_file = $ufile_path."/".$ufile_name.".htm";
    $make_file_guest = $ufile_path."/".$ufile_name.".js";
    //----文章类别与代码及栏目路径-----------
    $arttoptypes=split("--",$arttoptype);
    $artbigtypes=split("--",$artbigtype);
    $artstypes=split("--",$artstype);
    if($arttoptypes[0]==1) $toptypedir="joke";
    if($arttoptypes[0]==2) $toptypedir="love";
    if($arttoptypes[0]==3) $toptypedir="mm";
    if($artstype!=0)
    {
        $nowpos = "<a href='../../../".$toptypedir."'>".$arttoptypes[1]."</a>&gt;&gt;<a href='../../../".$toptypedir."/listbig.php?id=".$artbigtypes[0]."'>".$artbigtypes[1]."</a>&gt;&gt;<a href='../../../".$toptypedir."/lists.php?id=".$artstypes[0]."'>".$artstypes[1]."</a>";
    }
    else
    {
        $nowpos = "<a href='../../../".$toptypedir."'>".$arttoptypes[1]."</a>&gt;&gt;<a href='../../../".$toptypedir."/listbig.php?id=".$artbigtypes[0]."'>".$artbigtypes[1]."</a>";   
    }
    //----从数据库读取相似文章数--------------
    $likelimit = 10;
    $liketitles = split(",",$liketitle);
    $liketitlenum = count($liketitles);
    $likelimit = $likelimit - $liketitlenum + 1;
    //----文章中使用的图片数-----------------
    $pic_num = $ufile_pic_num;
    for($i=1;$i<=$ufile_pic_num;$i++)
    {
    $upicnewname1 = $ufile_path."/$ufile_name$i.jpg";
            $upicnewname2 = $ufile_path."/$ufile_name$i.gif";
            $upicnewname3 = $ufile_path."/$ufile_name$i.png";
            if((!file_exists($upicnewname1))&&(!file_exists($upicnewname2))&&(!file_exists($upicnewname3))) $pic_num--;
    }
    //----文章发布时间(Y-M-D)----------------
    $ufile_dtime_short = split(" ",$ufile_dtime);
    $ufile_dtime_short = $ufile_dtime_short[0];
    //----连接数据库、读取模板---------------
    $con = connectMySql();
    $fp = fopen($mod_file,"r");
    while(!feof($fp))
    {
        $mod.=fgets($fp,1024);
    }
    fclose($fp);
    //----获取相关文章-------------
    $sql = "Select title,filename,dtime From art where btypeid=".$artbigtypes[0]." order by ID desc limit 0,$likelimit";
    $rs = mysql_query($sql,$con);
    while($row=mysql_fetch_object($rs,$con))
    {
          $tmptitle=$row->title;
          $tmpfilename=$row->filename;
          $tmpdtime=$row->dtime;
          $tmpfileurl=$art_dir.getpath($tmpdtime)."/".$tmpfilename.".htm";
          $fileliststr.="<a href='$tmpfileurl'>·".$tmptitle."</a><br>\r\n";
    }
    if($likelimit!=10)
    {
        $sql = "Select title,filename,dtime From art where";
        for($i=0;$i<$liketitlenum;$i++)
        {
         if($i==1) $sql.=" ID=".$liketitle[i];
         else $sql.=" Or ID=".$liketitle[i];
        }
        $rs = mysql_query($sql,$con);
        while($row=mysql_fetch_object($rs,$con))
        {
          $tmptitle=$row->title;
          $tmpfilename=$row->filename;
          $tmpdtime=$row->dtime;
          $tmpfileurl=$art_dir.getpath($tmpdtime)."/".$tmpfilename.".htm";
          $fileliststr.="<a href='$tmpfileurl'>·".$tmptitle."</a><br>\r\n";
        }
    }
    //----创建文件---------------
    $artbody = stripslashes($artbody);
    $artbody = str_replace($base_url,"",$artbody);
    if(ishtml==0)
    {
         $artbody=str_replace("\r","",$artbody);
         $artbody=str_replace("\n","<br>\r\n",$artbody);
         $artbody=str_replace("  ","&nbsp;&nbsp;",$artbody);
    }
    $mod = str_replace("<!--title-->",$title,$mod);
    $mod = str_replace("<!--likeart-->",$fileliststr,$mod);
    $mod = str_replace("<!--dtime-->",$ufile_dtime_short,$mod);
    $mod = str_replace("<!--writer-->",$writer,$mod);
    $mod = str_replace("<!--source-->",$source,$mod);
    $mod = str_replace("<!--position-->",$nowpos,$mod);
    $mod = str_replace("<!--body-->",$artbody,$mod);
    $mod = str_replace("<!--pllink-->",$ufile_name,$mod);
    $mod = str_replace("<!--pljs-->","<script src='".$ufile_name.".js'></script>",$mod);
    $fp = fopen($make_file,"w");
    fputs($fp,$mod);
    fclose($fp);
    $fp = fopen($make_file_guest,"w");
    fputs($fp,"document.write(\"--\");\r\n");
    fclose($fp);
    //----把文章信息记录到数据库---------
    $insertQuery="INSERT INTO art (typeid, btypeid, stypeid, title, source, writer, keyword, picture, filename, userid, isCheck, click, dtime) VALUES ('".$arttoptypes[0]."','".$artbigtypes[0]."', '".$artstypes[0]."', '$title','$source', '$writer', '$keyword','$pic_num', '$ufile_name', '0','1', '0', '$ufile_dtime')";
    mysql_query($insertQuery,$con);
    //----返回成功信息-------------------
    ?>
    这里程序完全没变,就是改了顺序
    ---------------------------------
    我实在搞不懂,为什么会有这样的问题