Php While循环导致500内部服务器错误
如果我注释掉while循环,我的代码就会工作。我从来没有遇到过while循环的问题。错误显示为500-内部服务器错误“您正在查找的资源有问题,无法显示。”感谢您的帮助Php While循环导致500内部服务器错误,php,php-5.6,Php,Php 5.6,如果我注释掉while循环,我的代码就会工作。我从来没有遇到过while循环的问题。错误显示为500-内部服务器错误“您正在查找的资源有问题,无法显示。”感谢您的帮助 ini_set('memory_limit', '2048M'); ini_set('display_errors',1); ini_set('display_startup_errors',1); error_reporting(-1); $conn = odbc_connect("Driver
ini_set('memory_limit', '2048M');
ini_set('display_errors',1);
ini_set('display_startup_errors',1);
error_reporting(-1);
$conn = odbc_connect("Driver={SQL Server};Server=name; Database=main;", "user", "") or die ('001 DB Connection Failed.');
$final = trim($_POST['po']);
//$final = "1234567','1245698; this is what this variable looks like.
$sql = "select * from Table where id in ('$final')";
$table = '';
$query = odbc_exec($conn, $sql);
echo $sql;
$table = '<table class="table table-hover">
<thead>
<tr>
<th>header</th>
<th>header</th>
<th>header</th>
<th>header</th>
<th>header</th>
<th>header</th>
</tr>
</thead>
<tbody>';
while ($dataRow = odbc_fetch_array($query))
{
$table .= '<tr>
<td>'. $dataRow['data1'] .'</td>
<td>'. $dataRow['data1'] .'</td>
<td>'. $dataRow['data1'] .'</td>
<td>'. $dataRow['data1'] .'</td>
<td>'. $dataRow['data1'] .'</td>
<td>'. $dataRow['data1'] .'</td>
</tr>';
}
$table .= ' </tbody>
</table>';
echo $table;
?>
ini_集('memory_limit','2048M');
ini设置(“显示错误”,1);
ini设置(“显示启动错误”,1);
错误报告(-1);
$conn=odbc_connect(“Driver={sqlserver};Server=name;Database=main;”、“user”、“”)或die(“001 DB连接失败”);
$final=修剪($_POST['po']);
//$final=“1234567','1245698;这就是这个变量的样子。
$sql=“从id所在的表(“$final”)中选择*”;
$table='';
$query=odbc\u exec($conn,$sql);
echo$sql;
$table='1
标题
标题
标题
标题
标题
标题
';
while($dataRow=odbc\u fetch\u数组($query))
{
$table.='
“.$dataRow['data1']”
“.$dataRow['data1']”
“.$dataRow['data1']”
“.$dataRow['data1']”
“.$dataRow['data1']”
“.$dataRow['data1']”
';
}
$table.='
';
echo$表;
?>
我将取消对while循环的注释,但对其中的块进行注释。
如果不是500,则表示结果中不存在$datarow['data1']
其次
$sql=“从id所在的表(“$final”)中选择*;
将给您一个错误的查询。
$final
将不需要正确的引号/单引号。不要在客户端查找服务器错误。转到服务器并查看错误日志。500错误是一条通用错误消息,几乎涵盖了脚本可能出错的每一件事。请检查服务器错误日志以找出原因确切的错误消息。我将检查odbc_exec()
的返回值$query
,它可能是FALSE
,而不是odbc结果标识符。它返回资源id#2