简体   繁体   English

遇到非数值 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警告:在第 349 行的 /home/u914452720/domains/e-gilius.com/public_html/system/storagefnpzt1uybylm/modification/admin/model/catalog/manufacturer.php 中遇到非数字值警告:在/home/u914452720/domains/e-gilius.com/public_html/system/storagefnpzt1uybylm/modification/admin/model/catalog/manufacturer.php 在第 349 行

I get this error when I execute delete function: admin/controller/catalog/manufacturer_download.php执行 delete function: 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);
        }
    }

If I var_dump($entryID) it gives result: string(1) "5"如果我 var_dump($entryID) 它给出结果: string(1) "5"

admin/model/catalog/manufacturer.php admin/model/catalog/manufacturer.php

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

Where I made mistake?我在哪里犯错了?

You are using + in query that is wrong not need that use following code您在查询中使用 + 是错误的,不需要使用以下代码

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

You are mixing up the string concatenation:您正在混淆字符串连接:

change改变

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

to

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

The error comes from trying to add string and numbers together:该错误来自尝试将字符串和数字相加:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM