douhuan1937 2014-04-29 09:05 采纳率: 0%
浏览 47

在php文件中包含('xyz.php')不起作用

I'm trying to include a php file inside another php file, but it is not working and I don't know why.

Moreover, I'm getting no erroes. allow_url_include is enabled in php.ini file.

I'm using XAMPP server.

Below here is part of my code:

q.php

<div class="article">

<? php
include ('a.php'); 
?>
</div>

where a.php simply has echo statement:

echo "hello";

I'm posting bigger section of my code now.

<div class="artical">
    <?php
        $username = "root";
        $password = "";
        $database = "techinsight";
        $server   = "127.0.0.1";

        $db_handle = mysql_connect($server, $username, $password);
        $db_found  = mysql_select_db($database, $db_handle);

        if ($db_found) 
        {
            $SQL    = "SELECT * from questions";
            $result = mysql_query($SQL);

            while($db_field=mysql_fetch_assoc($result))
            {
                $x = $db_field['Qid'];

                while($x==1 && $x==NULL)
                {
                    $SQL      = "SELECT * from questions";
                    $result   = mysql_query($SQL);
                    $db_field = mysql_fetch_assoc($result);

                    $x        = $db_field['Qid'];
                }
            }

            if($x==$x) 
            {
                for($x; $x>0; $x--)
                {
                    $SQL      = "SELECT * from questions WHERE Qid=$x";
                    $result   = mysql_query($SQL);
                    $db_field = mysql_fetch_assoc($result);
                    $str_que  = $db_field['question'];

                    echo "<div class='dabba'>
                    <div class='block_a'> <?php include('a.php'); ?>  //here it is.
                    </div> <br>
                    <div class='block_b'>
                    it is 2nd section. <br>
                    </div><br>
                    <div class='block_c'>
                    last one.<br>  </div>

                    </div>  <br><br>";      
                }
            }                                    
        }     
    ?> 
</div>
  • 写回答

3条回答 默认 最新

  • dongpao1873 2014-04-29 09:08
    关注

    Try:

    <?php //Before you had <? php <--
    include "a.php";
    ?>
    

    Make sure the files are in the same directory.

    评论

报告相同问题?

悬赏问题

  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥15 帮我写一个c++工程