补充一下。
如果在index.php中,直接用PHP脚本include("votes.php");是可以正常运行的。就是Smarty后无法正常运行,奇怪。

解决方案 »

  1.   

    votes.php是没有问题,但是显示和投票是写在一个页里的,很杂乱,大概是长成这样。//定义动作页
    $action  = $_GET['action'];
    switch($action)
    {
    case 'show': showVotes(); break;  //处理投票和显示投票结果页面
    default: votes();  //显示投票页面
    }//显示投票页面
    function votes()
    {
       ……代码……
    }//处理投票和显示投票结果页面
    function showVotes()
    {
       ……代码……
    }<!--还有段JS代码:用来控制打开新窗口大小的-->
    <script language="javascript">
    var   wWidth=650;   
    var   wHeight=500;  
    function setAction()
    {
        form.action="?action=show";
        form.target="a1";
        window.open("about:blank","a1","width='+wWidth+',height='+wHeight+',left="+(window.screen.width-wWidth)/3+",top="+(window.screen.height-wHeight)/3+",status=no,location=no,toolbar=no, directories=no,menubar=no");
        form.submit();
    }
    </script>
      

  2.   

    try:
    =======================
    {literal}
    <script language="javascript">
    ...
    ..
    .
    .
    .
    .
    </script>
    {/literal}
      

  3.   

    谢谢你的回答,但是我试过了,不管用。votes.php没有使用模板,只是要include我看过了template_c下编译过的index.php文件代码,它把{include_php file="votes.php"}生成了如下代码:
    <?php
    require_once(SMARTY_CORE_DIR . 'core.smarty_include_php.php');
    smarty_core_smarty_include_php(array('smarty_file' => "votes.php", 'smarty_assign' => '', 'smarty_once' => false, 'smarty_include_vars' => array()), $this);
    ?>我在编译过的文件中把以上代码改成了:include("votes.php");votes.php无法正常工作。只有直接再未编译的index.php中include("votes.php");  votes.php才能正常工作。搞不懂index.php和index.htm之间的微妙关系。唉……头大。
      

  4.   

    include不好用啊。不是符号问题,就是不能编译。。换个方式把
      

  5.   

    要用相对路径就要用 $trusted_dir
      

  6.   

    谢谢各位回答,我试过了。也不是路径的问题。xiongbing529(代码人生)说的对,是编译问题了。问题就出在被编译的文件中,可是有什么好的解决方式呢?唉……
      

  7.   

    smarty怎么被楼主搞得这么复杂,
      

  8.   

    谢谢 zhangli(我来也!)虽然没有解答问题的关键所在,但是给出了十分好的解决方案。等结题了,也给你一半分吧。
      

  9.   

    你那个
    {include_php file="votes.php"}
    改成
    {php}
        include("votes.php");
    {/php}
    这样试试