繁体   English   中英

关闭PHP中包含的文件

[英]close the included file in php

我正在尝试通过将pro_id传递给方法来更改MySQL查询中的pro_id,它正在打印表格。

注意:第2行上的C:\\ WAMP64 \\ WWW \\ DASHBOARD \\ CONFIG2.PHP中已经定义了恒定服务器
注意:常量用户名已经在C:\\ WAMP64 \\ WWW \\ DASHBOARD \\ CONFIG2.PHP在线3中定义
注意:在第4行的C:\\ WAMP64 \\ WWW \\ DASHBOARD \\ CONFIG2.PHP中已经定义了恒定密码
注意:常量数据库已经在第5行的C:\\ WAMP64 \\ WWW \\ DASHBOARD \\ CONFIG2.PHP中定义

这些错误。

我的代码是这样的,

<?php
// Defining function
function project($a){

            echo '<DOCTYPE html>
            <head>
                <link rel="stylesheet" type="text/css" href="http://localhost/Dashboard/css/table_css.css">

            </head>
            <section>
            <body>';

         include("C:\wamp64\www\DashBoard\Config2.php");

          $sql = "select total_tc,passed,failed,blocked, (total_tc-passed-failed-blocked) as notrun from (select * from (select version_id as version_id from testcases) as t0, (select count(tc_id) as total_tc from testcases where testcases.pro_id=$a) as t,(select count(tc_result) as passed from executions join testcases on testcases.id=executions.parent_id where tc_result='p' and testcases.pro_id=$a  )as t2,
                        (select count(tc_result) as failed from executions join testcases on testcases.id=executions.parent_id where tc_result='f' and testcases.pro_id=$a)as t3,(select count(tc_result) as blocked from executions join testcases on testcases.id=executions.parent_id where tc_result='b' and testcases.pro_id=$a)as t4) as final where version_id= 1 limit 1;";

          $query = mysqli_query($db, $sql);
          echo'<div class="tbl-header">
                <table cellpadding="0" cellspacing="0" border="0">
                    <thead>
                        <tr>
                         <th>Total Testcase</th>
                         <th>Passed</th>
                         <th>Failed</th>
                         <th>Blocked</th>
                         <th>Not run</th>
                      </tr>
                    </thead>
                </table>
          </div>
       <div class="tbl-content">
         <table cellpadding="0" cellspacing="0" border="0">';

             while ($row = mysqli_fetch_array($query))
               {
               echo '<tr>

                <td>'.$row['total_tc'].'</td>
                <td>'.$row['passed'].'</td>
                <td>'.$row['failed'].'</td>
                <td>'.$row['blocked'].'</td>
                <td>'.$row['notrun'].'</td>

              </tr>';
             }
             echo'
        </tbody>
      </table>
    </div>
  </section>
</html>';
}
// Calling function
for ($x = 1; $x <8; $x++) {
    project($x);
} 
?>

并且Config2.php文件包含

<?php
   define('SERVER', '192.168.0.7:3306');
   define('USERNAME', 'Deepak');
   define('PASSWORD', 'test@123');
   define('DATABASE', 'dashtest');
   $db = mysqli_connect(SERVER,USERNAME,PASSWORD,DATABASE);
?>

谁能帮我解决这个问题?

您将在函数中包含带有常量的文件:

     include("C:\wamp64\www\DashBoard\Config2.php");

因此,第二次调用函数时,您将收到这些警告。

将文件包含在函数外部(并在需要时将数据库连接作为参数传递)或使用include_once

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM