2013-12-16 91 views
-3

我在使用mysql时遇到一些问题。而我完全不知道!为什么不能处理这个查询?(mysql,php)

这问题是...

$sql = "insert into Write_Member_Comment(writer, passwd, commentID) 
        values('test', '$passwd' '$commentID')"; 


mysql_query($sql, $connect); 
echo mysql_error(); 

我暂时填补作家 '测试'(orginally这是 '$作家'),但结果是...

'Column count doesn't match value count at row 1' 

这里的我的Write_Member_Comment表。

create table Write_Member_Comment(
writer  char(30) not null, 
passwd  char(30) not null, 
commentID int not null, 
FOREIGN KEY (commentID) REFERENCES PostComment(commentID) ON DELETE CASCADE ON UPDATE CASCADE) engine=InnoDB character set=utf8; 

为什么不工作?

+5

你错过了最后两个值之间的逗号。 – andrewsi

+4

这个问题似乎是脱离主题,因为它是关于语法错误 – Kermit

回答

3

你缺少一个逗号,它应该是:

$sql = "insert into Write_Member_Comment(writer, passwd, commentID) 
       values('test', '$passwd', '$commentID')"; 
+0

哦......!我真笨。对不起,谢谢!我得买眼镜! – Pororoca

相关问题