在布尔值上调用成员函数 execute()


Call to a member function execute() on boolean

我想选择一个年份,它向我显示所选年份的所有数据,但每次它都显示此错误: 在布尔值上调用成员函数execute()

请问为什么会出现?

这是我的查询:

$sql = (" SELECT code,supplier,date FROM suppliers WHERE
  YEAR(date) = $date ");

这是我的代码:

  <?php
 if(isset($_POST['submit'])) 
 {
 $date = $_POST['date'];
 $sql = (" SELECT code,supplier,date FROM suppliers WHERE YEAR(date) = $date 
  ");
$connexion->exec ( "set names utf8" );   
$reqd = $connexion->prepare($sql);
$reqd->execute();
$query = $reqd -> fetchAll(PDO::FETCH_ASSOC);
 }
?>
<form method="POST" action="">  
   <select class="form-control select2" style="width: 100%;">
      <option selected="selected">2016</option>
      <option>2015</option>
      <option>2014</option>
   </select>
   <button type="submit" name="submit" class="btn btn-primary">
      <span class="glyphicon glyphicon-ok"></span> Submit
   </button>
  </form>
   <table id="example1" class="table table-bordered table-striped">
    <thead>
      <tr>
     <? if(isset($_POST['date']))  { ?>
        <th style="text-align:center">code</th>
        <th style="text-align:center">supplier</th>
        <th style="text-align:center">date</th>
     <? } ?>     
                </tr>
            </thead>
            <tbody>
               <?php
                  foreach ( $query as $q => $r ) :
                  ?>
              <tr style="text-align: center;">
                <td><? echo $r['code']; ?></td>
                <td><? echo $r['supplier']; ?></td>
                <td><? echo $r['date']; ?></td>
                </tr>
                  <?php 
                  endforeach; 
                  ?>
            </tbody>
          </table>

谢谢

name属性放入没有名称的选定中未在post中设置

<select name="date" class="form-control select2" style="width: 100%;">