当然不行!!!
你把php的输出放在js脚本里,内容又不符合js语法。那怎么可以呢?

解决方案 »

  1.   

    在 - 2 - 中修改:   echo $newstype . "<br />\n";   改为   echo "document.write(" . $newstype . ")";也不行
      

  2.   

    放在js脚本里的东西要符合js的语法
      

  3.   

    你还是先将文件 1 生成的代码是单独放到 <script language="JavaScript"> <script>中,检查代码是否符合JavaScript语法要求。
      

  4.   

    xuzuning(唠叨),能示范写一下吗?
      

  5.   

    试试echo mysql_error();
    换成
    echo "document.write(".mysql_error().");";
    echo $newstype . "<br />\n";   
    改为
       echo "document.write(" . addslashes(str_replace("\r\n",'\r\n',$newstype)) . ")";
      

  6.   

    不好意思
    echo "document.write(" . addslashes(str_replace("\r\n",'\r\n',$newstype)) . ")";
    换成
    echo "document.write(" . str_replace("\r\n",'\r\n',addslashes($str)) . ")";
      

  7.   

    u cannot write php codes in js codes,u should use php to echo the whole js function.
      

  8.   

    like:
    <?php
     echo "<script language=\"javascript\">";
     echo "alert(\"success!\");";
     echo "</script>";
    ?>