Forum Moderators: coopster

Message Too Old, No Replies

PMs system

         

fricx

7:45 pm on Nov 18, 2007 (gmt 0)

10+ Year Member



Hello,

I am fighting with this problem over a week, so if someone can help please do.

I am building a private messaging system and i have a member system that i made. It contains ID (auto increment), nick, password...

The problem is that i don't know how to insert private message that is being sent to user. There is no insert WHERE statement. Does anyone know how to insert private message WHERE id of user = $someuser.

Please help.

PHP_Chimp

11:52 pm on Nov 18, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



From mysql manual -
INSERT [LOW_PRIORITY ¦ DELAYED ¦ HIGH_PRIORITY] [IGNORE]
[INTO] tbl_name [(col_name,...)]
VALUES ({expr ¦ DEFAULT},...),(...),...
[ ON DUPLICATE KEY UPDATE col_name=expr, ... ]

Or:

INSERT [LOW_PRIORITY ¦ DELAYED ¦ HIGH_PRIORITY] [IGNORE]
[INTO] tbl_name
SET col_name={expr ¦ DEFAULT}, ...
[ ON DUPLICATE KEY UPDATE col_name=expr, ... ]

Or:

INSERT [LOW_PRIORITY ¦ HIGH_PRIORITY] [IGNORE]
[INTO] tbl_name [(col_name,...)]
SELECT ...
[ ON DUPLICATE KEY UPDATE col_name=expr, ... ]


So the third one may help.
"INSERT INTO <table_name> SET 'id'=$someuser";

d40sithui

3:53 pm on Nov 19, 2007 (gmt 0)

10+ Year Member



fricx,
i think it would be easier if you have least one other table than your current one to contain all messages. For example create a table named privateMessages that contains messageID(int auto_increment pk),from(int), to(int), message(text), date(date), seen(int). the from and to fields would contain the userID of the sender and recipient, respectively.