[英]While Loop causing 500 Internal Server error
如果我注释掉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={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;
?>
我将取消注释while循环,但是注释其中的块。 如果不是500,则表示结果中不存在$ datarow ['data1']。
其次$sql = "select * from Table where id in ('$final')";
将给您一个残破的查询。 $final
不需要正确的引号/单引号。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.