i have created a DB with 3 columns: aid, qid and message.
aid is a foreign key which will be commond with another table. comments is a varchar which stores user comments
its partially working. the problem is aid is not adding duplicate values. suppose i want to add comments related to specific aid. there are 18 aid's in all. and i want to filter the comments according to aid's. the table is not adding a duplicate aid.
this is the query I am using in php:
$query = "UPDATE answers SET acount = acount + 1 WHERE aid = $vote";
$result = mysql_query($query);
$cadd = "INSERT INTO comments (aid, msg) VALUES ('$vote','$comment')";
mysql_query($c开发者_高级运维add);
what am i doing wrong. i am attaching a screenshot of the DB structure.
caution: extreme n00b.
It looks like aid is your primary key, which should be unique.
Show table comments. I would guess the PK there is aid.
b.t.w your code is vulnerable to sql injection (unless this is only for the sake of debugging).
精彩评论