使用mysqli bind_param错误“使用字符串转换字符串”

时间:2017-06-09 11:05:22

标签: php arrays mysqli

$searchTerm = isset($_GET['txtSearch']) ? $_GET['txtSearch'] : '';
$searchTerm = strtolower($searchTerm);
$searchTerm = strip_tags($searchTerm);
$searchTerm = trim($searchTerm," "); 

$keywords = explode(" ",$searchTerm); // break down search term into individual keywords

$in = join(',', array_fill(0, count($keywords), '?'));
$select = <<<SQL
    SELECT * 
    FROM m_products
    WHERE product_title IN ($in);
SQL;
$statement = $con->prepare($select);
$statement->bind_param(str_repeat('s', count($$keywords)), ...$keywords); //s = string, d = double, i = integer
$statement->execute();

我从上面的代码中收到以下错误:

  
      
  • 注意:
  • 中的数组到字符串转换   
  • 注意:未定义的变量:
  • 中的数组   
  • 警告:mysqli_stmt :: bind_param():无效的类型或
  • 中指定的类型   

如何解决此错误?

1 个答案:

答案 0 :(得分:1)

正如我在上面的评论中所说:

self.numbersStackViewTopMarginConstriant.constant = self.view.frame.size.height
UIView.animate(withDuration: 0.5, animations: {

            self.view.layoutIfNeeded()

        }) { (Bool) in

$statement->bind_param(str_repeat('s', count($$keywords)), ...$keywords); //s = string, d = double, i = integer 中有一个双$ $$删除一个$,应该解决错误。