0

我的朋友有这个疑问:

preg_match_all("#<description>(.*?)</description>#s",$Rss,$message);  
$count = count($message[0]);
$message[0] = str_replace('<description><![CDATA[',' ',$message[0]);
$message[0] = str_replace('</description>]]>',' ',$message[0]);

for($i=0;$i<$count;$i++){    

$db->query("INSERT INTO ".prefix."topicmessage (message,forumid,catid) VALUES ('".$message[0][$i]."','".$MyRows['forumid']."','".forums('CATID',$MyRows['forumid'])."')",__file__,__line__);

}


但他 qet 这个数据库错误:

DATABASE ERROR: can not output data in datebase [Duplicate entry '0' for key 1] in C:\AppServ\www\ala\Rss_Caller.php on line 57

如何解决?

4

2 回答 2

0

您有一个没有自动增量的主键字段,您没有在查询中给出值。

可能类似于“topicmessageid”

所以向该字段添加一个自动增量。

于 2013-04-24T13:25:39.083 回答
0

这意味着您正在尝试将记录插入数据库,其中0作为键值,这可能是主键、辅助键或唯一约束。

检查您插入的主键的值,如果它不是编程错误,请尝试更改您的 AUTO_INCREMENT

希望这会有所帮助,不要犹豫再问更多问题=)

于 2013-04-24T13:24:39.223 回答