我想寻求您的帮助,我在插入中收到了此error
。
Data truncated for column 'code' at row 1</p>
<p>INSERT INTO `permissions` (`employeeId`, `code`) VALUES ('2', '451</td');
我想出了什么问题,它是"
这是我的 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);
}
如果问题<td
,那么可以使用strip_tags轻松解决
$text = '451</td';
echo strip_tags($text);
echo "'n";
**OUTPUT** : 451
既然你已经提到<td
问题所在
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**
这是我的 php:
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);
}
还要检查与您的问题相似的答案
数据截断列 xxxx-at-row-1
mysql-data-truncated-for-column-advance-at-row-1
错误数据截断了列纬度行 1
列的数据截断
从上面的链接,我也建议您按照 kalp 在下面的答案中的建议检查您的服务器模式设置
第1 行第 XX 列的数据被截断
SQL 模式
您尝试输入的数据长度超过列定义允许的数据。请提供您使用的查询供我们查看。此外,谷歌搜索错误消息还产生了:
http://forums.mysql.com/read.php?11,132672,132672#msg-132672http://dev.mysql.com/doc/refman/5.0/en/server-sql-mode.html建议的解决方案是修改服务器的"严格模式"设置:
当本手册提到"严格模式"时,它是指至少启用了STRICT_TRANS_TABLES
或STRICT_ALL_TABLES
之一的模式。