我有一个以前从未遇到过的奇怪问题。
我description
在 mysql 表中有一个名为list_items
.
在某些行中,描述为空,而在某些行中则不是。格式是中文本,但是当我将其更改为类似 VARCHAR(1000) 时也会出现同样的问题。
这是一个简单的查询:
$result=mysql_query("select * from list_items where list_id='$id' order by position desc") or die(mysql_error());
while($iteminfo=mysql_fetch_assoc($result)){
print_r($iteminfo);
}
它给出了这样的东西:
Array (
[id] => 85 [list_id] => 16 [position] => 4
[item] => How To Be Richer Smarter And Better Looking Than Your Parents
[voted_up] => 0 [voted_down] => 0
[small_image] => http://ecx.images-amazon.com/images/I/51tdjl56TwL._SL160_.jpg
[large_image] => http://ecx.images-amazon.com/images/I/51tdjl56TwL.jpg
[asin] => 1591845440 [description] => undefined [author] => Zac Bissonnette
[publish_date] => 2012-04-24 [genre] => )
描述列始终为“未定义”,无论它是否为空。有任何想法吗?
表结构:
CREATE TABLE IF NOT EXISTS `list_items` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`list_id` int(11) NOT NULL,
`position` int(11) NOT NULL,
`item` varchar(512) NOT NULL,
`voted_up` int(11) NOT NULL,
`voted_down` int(11) NOT NULL,
`small_image` varchar(128) NOT NULL,
`large_image` varchar(128) NOT NULL,
`asin` varchar(16) NOT NULL,
`description` mediumtext NOT NULL,
`author` varchar(128) NOT NULL,
`publish_date` varchar(16) NOT NULL,
`genre` varchar(128) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=107 ;
var_dump 返回:
array(13) { ["id"]=> string(2) "87" ["list_id"]=> string(2) "16" ["position"]=> string(1) "2" ["item"]=> string(22) "Game Of Thrones Book 1" ["voted_up"]=> string(1) "1" ["voted_down"]=> string(1) "0" ["small_image"]=> string(61) "http://ecx.images-amazon.com/images/I/51VcGBtiLTL._SL160_.jpg" ["large_image"]=> string(53) "http://ecx.images-amazon.com/images/I/51VcGBtiLTL.jpg" ["asin"]=> string(10) "0553386794" ["description"]=> string(0) "" ["author"]=> string(18) "George R.R. Martin" ["publish_date"]=> string(10) "2011-03-22" ["genre"]=> string(0) "" }
但echo $iteminfo['description']
仍然给出'未定义'。