drd99007 2019-04-26 14:57
浏览 47

注意:wpdb :: prepare被错误地调用

I am getting this error when inserting the data in To wordpress table using placeholder inside foreach() loop.

Notice: wpdb::prepare was called incorrectly. The query argument of wpdb::prepare() must have a placeholder. Please see Debugging in WordPress for more information.



 $query = "INSERT INTO competitor_units (competitor_id, unit_size, width, length, square_feet, square_foot_price, unit_price, climate_controlled, amenities, unit_url, scraper_source, latitude, longitude, quantity, hash, last_updated) VALUES ";

 foreach ($response as $key => $value) {
        array_push($values, $competitor_id, $value['unit_size'], $value['width'], $value['length'], $value['square_feet'], $value['square_foot_price'], $value['unit_price'], $value['climate_controlled'], $value['amenities'], $value['unit_url'], $value['scraper_source'], $value['latitude'], $value['longitude'], 1, $value['hash'], date('Y-m-d H:i:s', strtotime($value['last_updated'])));
        $place_holders[] = "('%d', '%s', '%d', '%d','%d', '%d', '%d', '%d', '%s', '%s', '%s', '%d','%d','%d','%s','%s')";

  }
  $query .= implode(',', $place_holders);
  return $this->dbObj->query( $this->dbObj->prepare("$query ", $values));

Thanks in advance.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 对于这个复杂问题的解释说明
    • ¥50 三种调度算法报错 有实例
    • ¥15 关于#python#的问题,请各位专家解答!
    • ¥200 询问:python实现大地主题正反算的程序设计,有偿
    • ¥15 smptlib使用465端口发送邮件失败
    • ¥200 总是报错,能帮助用python实现程序实现高斯正反算吗?有偿
    • ¥15 对于squad数据集的基于bert模型的微调
    • ¥15 为什么我运行这个网络会出现以下报错?CRNN神经网络
    • ¥20 steam下载游戏占用内存
    • ¥15 CST保存项目时失败