Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/238.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 我的插入代码有什么问题?它会出现意外错误?_Php_Mysql_Codeigniter - Fatal编程技术网

Php 我的插入代码有什么问题?它会出现意外错误?

Php 我的插入代码有什么问题?它会出现意外错误?,php,mysql,codeigniter,Php,Mysql,Codeigniter,我想请求您的帮助,我在我的插入中收到了这个错误 Data truncated for column 'code' at row 1</p> <p>INSERT INTO `permissions` (`employeeId`, `code`) VALUES ('2', '451</td'); 您试图输入的数据长度超过了列定义允许的长度。请提供您用于我们查看的查询。此外,谷歌搜索错误消息还产生: 建议的解决方案是修改服务器的“严格模式”设置: 当本手册提到“严格模

我想请求您的帮助,我在我的插入中收到了这个
错误

Data truncated for column 'code' at row 1</p>
<p>INSERT INTO `permissions` (`employeeId`, `code`) VALUES ('2', '451</td');

您试图输入的数据长度超过了列定义允许的长度。请提供您用于我们查看的查询。此外,谷歌搜索错误消息还产生:

建议的解决方案是修改服务器的“严格模式”设置:


当本手册提到“严格模式”时,它意味着至少一个
strict\u TRANS\u表
strict\u ALL\u表
被启用的模式。

如果问题是
,除非我们看到插入的来源,否则我们无法真正判断。显示PHP代码为什么存在
,这就是我要弄明白的。我不知道它是从哪里来的,最好的办法是删除你的问题不清楚。请解释你想做什么。
if (count($permissionsArray) > 0) {
            // Insert the new permissions to the database.
            $sSQL = "INSERT INTO `permissions` (`employeeId`, `code`) VALUES ";
            foreach ($permissionsArray as $item) {  
                $sSQL.= "('$eid', '$item'),";
            }
            $sSQL = substr($sSQL, 0, strlen($sSQL)-1).";";
            // Execute Query.
            $this->db->query($sSQL);
        }
  $text = '451</td';
echo strip_tags($text);
echo "\n";

**OUTPUT** : 451
I figured out whats wrong and it's the "</td" and that is unacceptable in my database. Does anyone knows how to remove that "</td". - **from question**
if (count($permissionsArray) > 0) {
            // Insert the new permissions to the database.
            $sSQL = "INSERT INTO `permissions` (`employeeId`, `code`) VALUES ";
            foreach ($permissionsArray as $item) {  
                            $item = strip_tags($item);//removing html tag
                $sSQL.= "('$eid', '$item'),";
            }
            $sSQL = substr($sSQL, 0, strlen($sSQL)-1).";";
            // Execute Query.
            $this->db->query($sSQL);
        }