我在mysql查询失败时包含一个php文件。包含文件不起作用。以下是不起作用的片段。请检查。
$countsql2='SELECT * from table_name';
$countsql3 = mysqli_query($mysqli, $countsql2) or die("
<div id='fail_container'>
<div id='fail_grid'>
<span class='searched_invalid'>There seems to be an issue with the server connectivity.Please Try again later.</span><br />
<span class='searched_invalid'>We have an option to check out the categories here</span>
</div>
</div>"
include 'file1.php');
我想在查询失败时显示包含的php文件。但是当我在模具零件中移除包含零件时,它运行正常。但我想用include php文件运行它。
请帮我纠正这个问题,或者是否可以通过其他方式完成。
答案 0 :(得分:1)
多数民众赞成因为die停止了您的申请。
你能做的是:
if ( !$countsql3 = mysqli_query( $mysqli, $countsql2 ) )
{
echo "<div id='fail_container'>
<div id='fail_grid'>
<span class='searched_invalid'>There seems to be an issue with the server connectivity.Please Try again later.</span><br />
<span class='searched_invalid'>We have an option to check out the categories here</span>
</div>
</div>";
include('file1.php');
die;
}
答案 1 :(得分:0)
您应该在if
语句中执行此操作,如下所示:
$countsql2='SELECT * from table_name';
$countsql3 = mysqli_query($mysqli, $countsql2);
if (!$countsql3) {
echo "<div id='fail_container'>
<div id='fail_grid'>
<span class='searched_invalid'>There seems to be an issue with the server connectivity.Please Try again later.</span><br />
<span class='searched_invalid'>We have an option to check out the categories here</span>
</div>
</div>"
include 'file1.php';
exit;
}
答案 2 :(得分:0)
你应该试试......
的完整路径file1.php
如果file1.php仍然无法显示,您可以尝试使用$_SERVER["DOCUMENT_ROOT"];
获取根文件夹并添加当前位置。
error_reporting(E_ALL);
ini_set('display_errors', 1);
$countsql2='SELECT * from table_name';
if ( !$countsql3 = mysqli_query( $mysqli, $countsql2 ) )
{
echo "<div id='fail_container'>
<div id='fail_grid'>
<span class='searched_invalid'>There seems to be an issue with the server connectivity.Please Try again later.</span><br />
<span class='searched_invalid'>We have an option to check out the categories here</span>
</div>
</div>";
require('/full/path/to/file/file1.php');
}