我在jsp页面中嵌入了一个php,从url传过去的中文,在php中是乱码,我添加了header("Content-Type: text/html; charset=utf-8"); 结果报错 Warning: Cannot modify header information - headers already sent by

解决方案 »

  1.   

    在 header() 语句之前有输出了 
    把 header()放到输出之前!
      

  2.   

    header前貌似不能有任何输出。
      

  3.   

    header 已经放在php文件的最上面了,不行。这个php 是被一个jsp iframe 的
      

  4.   

    <tr vAlign=top style="cursor:hand" onclick="showDetail_erpforum(<?php $row['tid'] ?>);">
    <script language="javascript" type="text/javascript">
    function showDetail_erpforum(tid){
    alert("tid3333是多少 "+tid);
    var url = "http://10.222.1.104:8080/discuz/erp_sso.php?employeeid=<?php echo $employee_no; ?>&username_erp=<?php echo $employee_name; ?>&tid="+tid ;
    alert("url---"+url);
    window.open(url);
    }
    </script>
    alert()的 tid 居然是undefined 。 怎么回事啊?
      

  5.   

    我想你应该给 http://10.222.1.104:8080/discuz/erp_sso.php?employeeid=<?php echo $employee_no; ?>&username_erp=这个的代码吧。
      

  6.   

    <tr vAlign=top style="cursor:hand" onclick="showDetail_erpforum(<?php echo $row['tid'] ?>);">
      

  7.   

    <style type="text/css">
    .gray-dashed {
    border-bottom: #000 1px dashed;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 12px;
    color: #3c3c3c;
    LINE-HEIGHT: 16px
    }
    .list {
    LINE-HEIGHT: 16px
    }
    </style>
    <?php
    $employee_no = $_GET['employeeid'];
    $employee_name = $_GET['username_erp'];
    ?><?php
    $conn = mysql_connect("10.222.1.104","root","passw0rd");
        mysql_select_db("discuz");
        mysql_query("set names utf8;",$conn);
    $sql = "select * from cdb_posts p where p.fid =26 and subject <> '' ORDER by dateline desc limit 5 ";
    $rs = mysql_query($sql);
    ?>
    <script type="text/javascript">
    function showDetail_erpforum(tid){
    alert("tid3333是多少 "+tid);
    var url = "http://10.222.1.104:8080/discuz/erp_sso.php?employeeid=<?php echo $employee_no; ?>&username_erp=<?php echo $employee_name; ?>&tid="+tid ;
    alert("url---"+url);
    window.open(url);
    }
    </script>
    <?php  if(@mysql_num_rows($rs)>0){
              while ($row = mysql_fetch_array($rs, MYSQL_ASSOC)) {    ?>
      <table class=list border=0 cellSpacing=0 cellPadding=0 width="105%" align=center>
            <tr vAlign=top style="cursor:hand" onclick="showDetail_erpforum(<?php $row['tid'] ?>);">
              <td height="10" width="10" align="right" valign="bottom">&nbsp;
                <image width="10" height="10" src="./images/arrow.gif" />&nbsp;
              </td>
              <td height=10 align="left" valign="bottom" class="gray-dashed">
                <font style="font-size:12px;color:#353535"> &nbsp;&nbsp;
                  <?php echo $row['subject'] ?>
                </font>
              </td>
              <td height=10 align="right" valign="bottom" class="gray-dashed">&nbsp;
                <font style="font-size:12px;color:#353535"> 
    <? $d=date('Y-m-d',$row['dateline']); ?>          
                   [<?echo $d; ?>
                </font>]
              </td>
              <td width="5">&nbsp;</td>
            </tr>
    </table>
        <?php
            }
            mysql_close($conn);
        }
        ?>