I have a problem in php code inserting values into database (I use PHPMyAdmin).
My DATABASE has 3 tables:
Member
with this fields: MemberID, MemberNameRoom
with this fields: RoomID, RoomNameJoin
with this fields: MemberID, RoomID
The idea is to join the member in the room.
My query was
mysql_query("INSERT INTO join (RoomID, MemberID) VALUES ('121', '131')");
but unfortunately it does not work.
JOIN
is a reserved keyword. You might be able to escape it using backticks
INSERT INTO `join` (RoomID, MemberID) VALUES ('121', '131')
but I would suggest renaming the table if possible.
JOIN
is a reserved word in most flavours of SQL.
Try putting the database name before the table name
insert into dbname.join (RoomID,MemberID) ....
Or better yet, rename the table join
to something else.
Try putting the table name in backticks:
insert into `join` (RoomID,MemberID) values ('121', '131')
Because "join" is an SQL keyword, the parser will get confused if you try to also use it as a name without explicitly making it a name via the ticks.
In the future, you probably don't want to name tables as things that are already SQL keywords - instead, name them something more descriptive, like "RoomsAndMembers" or some such.
精彩评论