SQL LIKE query failing - fatal error in prepared statement

后端 未结 4 754
天涯浪人
天涯浪人 2021-01-15 20:32

I have the following code:

$countQuery = \"SELECT ARTICLE_NO FROM ? WHERE upper(ARTICLE_NAME) LIKE \'% ? %\'\";
if ($numRecords = $con->prepare($countQuer         


        
4条回答
  •  情书的邮戳
    2021-01-15 20:49

    Try the following instead:

    $countQuery = "SELECT ARTICLE_NO FROM ? WHERE upper(ARTICLE_NAME) LIKE ?";
    if ($numRecords = $con->prepare($countQuery)) {
        $numRecords->bind_param("ss", $table, "%$brand%");
        $numRecords->execute();
        $data = $con->query($countQuery) or die(print_r($con->error));
        $rowcount = mysql_num_rows($data);
        $rows = getRowsByArticleSearch($query, $table, $max);
        $last = ceil($rowcount/$page_rows);
    }
    

提交回复
热议问题