MySQLi准备声明

时间:2015-11-04 17:58:50

标签: php select mysqli prepared-statement

显然,当我尝试为SELECT查询执行prepare语句时,我会想念。

任何机构都可以告诉我正确的版本是什么:

$db = new mysqli($config_databaseServer, $config_databaseUsername ,$config_databasePassword, $config_databaseName);

if(isset($_POST['queryString'])) {
            $queryString = $db->real_escape_string($_POST['queryString']);

            if(strlen($queryString) >3) {

                $numberOfProducts = $_POST['numberOfProducts'];
                $numberOfBrands = $_POST['numberOfBrands'];
                $query = $db->prepare("SELECT name, image_url FROM `".$config_databaseTablePrefix."products` WHERE name LIKE '?%' LIMIT ?");
                $query->bind_param('ss', $queryString, $numberOfProducts);
                $query->execute();
                if($query) {
                   while ($result = $query ->fetch_object()) {
                code continues..

错误:

  

警告:mysqli_stmt :: bind_param():变量数量与预备语句中的参数数量不匹配

     

致命错误:调用未定义的方法mysqli_stmt :: fetch_object()

我只有两个变量?

0 个答案:

没有答案