doudian6229 2017-03-31 05:43
浏览 85
已采纳

致命错误:在null上调用成员函数prepare()

I'm getting this error and i can't find whats wrong.

I've read through the other posts about this error but none of them seemed to help.

Fatal error: Call to a member function prepare() on null on line 92

        <?php 


  include 'config.php';


   $lengd = $_POST["lengd"];
      $height = $_POST["height"];   
       $width = $_POST["width"];



     $min_lengd = $lengd * 0.9; $max_lengd = $lengd * 1.1;     
              $min_height = $height * 0.9; $max_height= $height * 1.1; 
                 $min_width = $width * 0.9; $max_width= $width * 1.1; 


$sql = "SELECT lengd, height, width FROM filters;

      WHERE $lengd BETWEEN :min_lengd AND :max_lengd

        AND $height BETWEEN :min_height AND :max_height

            AND $width BETWEEN :min_width AND :max_width

             LIMIT 2";

            $params = [
            'min_lengd' => $min_lengd,
               'max_lengd' => $max_lengd,
                  'min_height' => $min_height,
                   'max_height' => $max_height,
                      'min_width' => $min_width,
                        'max_width' => $max_width, ];


  $stmt = $conn->prepare($sql);  // LINE 92
  $stmt->execute($params);


?>
  • 写回答

2条回答 默认 最新

  • drsc10888 2017-03-31 06:34
    关注

    It looks like your $conn variable is not initilazied. I can't see in the code you've uploaded where you are initializing it..

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错
  • ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
  • ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载
  • ¥15 c#逐行读取txt文本,但是每一行里面数据之间空格数量不同
  • ¥50 如何openEuler 22.03上安装配置drbd
  • ¥20 ING91680C BLE5.3 芯片怎么实现串口收发数据
  • ¥15 无线连接树莓派,无法执行update,如何解决?(相关搜索:软件下载)
  • ¥15 Windows11, backspace, enter, space键失灵