遇到非数值 PHP MYSQL opencart

A non-numeric value encountered PHP MYSQL opencart

Warning: A non-numeric value encountered in /home/u914452720/domains/e-gilius.com/public_html/system/storagefnpzt1uybylm/modification/admin/model/catalog/manufacturer.php on line 349Warning: A non-numeric value encountered in /home/u914452720/domains/e-gilius.com/public_html/system/storagefnpzt1uybylm/modification/admin/model/catalog/manufacturer.php on line 349

执行删除功能时出现此错误: admin/controller/catalog/manufacturer_download.php

function delete(){
        // var_dump("I AM IN DELETE");
        $this->load->model('catalog/manufacturer');
        $postData = array();
        if(isset($_POST['submitdelete'])){
            //  var_dump("DELETE SUBMITTED");
            $entryID = $_POST['entryID'];// <-- gotta protect from sql injection.
            //  var_dump($entryID);
            $this->model_catalog_manufacturer->deleteManufacturersDownload($entryID);
        }
    }

如果我 var_dump($entryID) 它给出结果:string(1) "5"

admin/model/catalog/manufacturer.php

public function deleteManufacturersDownload($id){
        $this->db->query("DELETE FROM ". DB_PREFIX . "manufacturer_downloads WHERE id =" + "'"+$id+"'");
        return "success";
    }

我哪里弄错了?

您在错误的查询中使用 + 不需要使用以下代码

$this->db->query("DELETE FROM ". DB_PREFIX . "manufacturer_downloads WHERE id = '$id'");

您混淆了字符串连接:

改变

$this->db->query("DELETE FROM ". DB_PREFIX . "manufacturer_downloads WHERE id =" + "'"+$id+"'");

$this->db->query("DELETE FROM ". DB_PREFIX . "manufacturer_downloads WHERE id =" . "'" . $id . "'");

错误来自尝试将字符串和数字相加:

echo "FOO" + 1337; // Warning:  A non-numeric value encountered in[...]