Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/240.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP:为什么会出现语法错误,意外';endwhile';(结束时)?_Php - Fatal编程技术网

PHP:为什么会出现语法错误,意外';endwhile';(结束时)?

PHP:为什么会出现语法错误,意外';endwhile';(结束时)?,php,Php,PHP:为什么第38行出现语法错误,意外的'endwhile'(T_endwhile)?我第一次尝试用php和mysql创建一个论坛,我不确定我的代码出了什么问题 <?php session_start(); require"db_connect.php"; $sql = "SELECT forum_id, forum_name FROM forum_tbl"; if ($query = $db->prepare($sql)){ $query->bind_result

PHP:为什么第38行出现语法错误,意外的'endwhile'(T_endwhile)?我第一次尝试用php和mysql创建一个论坛,我不确定我的代码出了什么问题

<?php
session_start();
require"db_connect.php";

$sql = "SELECT forum_id, forum_name FROM forum_tbl";
if ($query = $db->prepare($sql)){
    $query->bind_result($f_id, $f_name);
    $query->execute();
    $query->store_result();
}else{
    echo $db->error;
}

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">

<head>
<title>Forum</title>
<meta/>
<style type="text/css">
</style>
</head>

<body>
<div class="container">
<div class="content">
    <table align="center" width="80%">
        <?php
        if($query->num_rows !==0)
        while($row = $query->fetch())
        ?>  
        <tr>
        <td><a href="forum.php?id=<?php echo $f_id?>"><?php echo $f_name;?>    </a></td>
        </tr>
        <?php endwhile; endif;?>    
    </table>
</div>
</div>
</body>
</html>

论坛

您在
if
while
中都缺少一个
。应该是

if($query->num_rows !==0):
while($row = $query->fetch()):
请参见末尾的
s


阅读更多信息。

那不是不合适吗?