致命错误:调用未定义的函数bind_param()

时间:2015-07-18 17:18:06

标签: php mysqli prepared-statement

我想使用mysql LIKE从数据库中检索学生姓名,我有以下表格

  <form action="search.php" method="POST">
        <input type="text" name="search" id="search-input">
        <input type="submit" value="Submit" id="submit">
  </form>

我的search.php

<?php 
        require_once 'db.php';
        if (isset($_POST['search']) && !empty($_POST['search'])) {
            $search_param = trim($_POST['search']);

            $slct_search = $db->prepare("SELECT student_name FROM student_details WHERE student_name LIKE ?") or die($db->error);
            $slct_search = bind_param('s', $search_param);
            $slct_search->execute();        
            $res = $slct_search->get_result();  
            if($res->num_rows) {            
                while ($result = $res->fetch_object()) {
                    echo $result->student_name;
                }
            } else {
                echo 'OOPS we had a problem';
            }   
        }
    ?>

当我点击提交按钮时,我收到以下错误

  

致命错误:调用未定义的函数bind_param()   第7行的F:\ xampp \ htdocs \ sel \ search.php

2 个答案:

答案 0 :(得分:1)

你试过了吗?

make otapackage

另请注意,您可以使用emulator,但仍然可以使用SQL注入。尝试做一些像:

$slct_search->bind_param('s', $search_param);

在这里阅读其他一些逃避:

答案 1 :(得分:0)

对于bind_param,请使用->

使用此$ slct_search-> bind_param

代替此$ slct_search = bind_param