我试图通过传递pro_id到方法来改变MySQL查询中的pro_id。它正在打印表。但它正在给出
注意:已在C:\ WAMP64 \ WWW \ DASHBOARD \ CONFIG2.PHP第2行中定义了常量服务器
注意:已在C:\ WAMP64 \ WWW \ DASHBOARD \ CONFIG2.PHP第3行中定义了常量用户名:
注意:已在C:\ WAMP64 \ WWW \ DASHBOARD \ CONFIG2.PHP ON中定义了常量密码LINE 4
注意:已在C:\ WAMP64 \ WWW \ DASHBOARD \ CONFIG2.PHP第5行中定义了常量数据库
这些错误。
我的代码是这样的,
<?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);
?>
任何人都可以帮我解决这个问题吗?
答案 0 :(得分:3)
您在函数中包含带常量的文件:
include("C:\wamp64\www\DashBoard\Config2.php");
因此,第二次调用您的函数时,您将收到这些警告。
将函数包含在函数外部(如有必要,将数据库连接作为参数传递)或使用include_once
代替。