-1

我有这两个mysql表:

--
-- Table structure for table `body`
--

DROP TABLE IF EXISTS `body`;
CREATE TABLE IF NOT EXISTS `body` (
`bChar` bigint(10) NOT NULL,
`bPart` bigint(10) NOT NULL,
`bStr` int(3) NOT NULL,
`bDur` int(3) NOT NULL,
`bItem` bigint(10) NOT NULL,
`bHealth` int(3) NOT NULL,
`bSpd` int(3) NOT NULL,
`bMaxDur` int(3) NOT NULL,
`bCurse` int(1) NOT NULL,
`bAct` int(1) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `partybody`
--

DROP TABLE IF EXISTS `partybody`;
CREATE TABLE IF NOT EXISTS `partybody` (
`pabChar` bigint(10) NOT NULL,
`pabPart` bigint(10) NOT NULL,
`pabStr` int(3) NOT NULL,
`pabDur` int(3) NOT NULL,
`pabItem` int(10) NOT NULL,
`pabHealth` int(3) NOT NULL,
`pabAct` int(1) NOT NULL,
`pabNum` int(4) NOT NULL,
`pabSlot` int(1) NOT NULL,
`pabSpd` int(3) NOT NULL,
`pabMaxDur` int(3) NOT NULL,
`pabCurse` int(1) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

这是正文中的数据:

(0, 25, 0, 0, 0, 120, 0, 0, 0, 1)   

我有这个 php 代码:

$query = "SELECT * FROM body WHERE bChar = ".$_SESSION['chNum'];
$result2 = mysql_query($query, $_SESSION['connect']) or die("Error 3:".mysql_error());
while($row2 = mysql_fetch_array($result2)) {
   query = "INSERT INTO partybody VALUES(".$_SESSION['chNum'].",".$row2['bPart'].",".$row2['bStr'].",".$row2['bDur'].",".$row2['bItem'].",".$row2['bHealth'].",1,1,1,".$row2['bSpd'].",".$row2['bMaxDur'].",".$row2['bCurse'].")";
  mysql_query($query, $_SESSION['connect']) or die("Error 4a:".mysql_error());
}

我刚刚添加$row2['bCurse']INSERT,我将错误消息从错误 4:更改为错误 4a:但是当我执行程序时,我得到了这个:

Error 4:Column count doesn't match value count at row 1. 

我尝试清除缓存,但没有帮助。想法?

4

1 回答 1

0

如果数据库仍然只填充测试数据,您可以输出所有查询字符串并目视检查是否有问题。寻找可能看起来像这样的查询部分number,,number

$query = "SELECT * FROM body WHERE bChar = ".$_SESSION['chNum'];
var_dump($query);
$result2 = mysql_query($query, $_SESSION['connect']) or die("Error 3:".mysql_error());
while($row2 = mysql_fetch_array($result2)) {
   query = "INSERT INTO partybody VALUES(".$_SESSION['chNum'].",".$row2['bPart'].",".$row2['bStr'].",".$row2['bDur'].",".$row2['bItem'].",".$row2['bHealth'].",1,1,1,".$row2['bSpd'].",".$row2['bMaxDur'].",".$row2['bCurse'].")";
   var_dump($query)
   //mysql_query($query, $_SESSION['connect']) or die("Error 4a:".mysql_error());
}

query顺便说一句,以下行中的错字前面缺少美元符号吗?

query = "INSERT INTO partybody VALUES(".$_SESSION['chNum'].",".$row2['bPart'].",".$row2['bStr'].",".$row2['bDur'].",".$row2['bItem'].",".$row2['bHealth'].",1,1,1,".$row2['bSpd'].",".$row2['bMaxDur'].",".$row2['bCurse'].")";
于 2012-05-08T13:20:01.517 回答