andrewjamesb Posted August 19, 2013 Share Posted August 19, 2013 Hi I would be ever so grateful if there is a PHP / MYSQL genius out there that can solve this annoying issue I have I have a member site with just 3 test members at present. Where users can simply send and receive internal messages to each other. The messaging system works to a fashion. However when a user goes to send a message to another user the following error occurs; Database error: Invalid SQL: insert into sky_message (to_id,from_id,subject,message,send_date) values('1','3','testy','another test',now())MySQL Error: 1062 (Duplicate entry '1' for key 1)Session halted. Database error: Invalid SQL: insert into sky_message (to_id,form_id,subject,message,send_date) values('4','2','test','another test',now())MySQL Error: 1062 (Duplicate entry '2' for key 2)Session halted. Database error: Invalid SQL: insert into sky_message (to_id,form_id,subject,message,send_date) values('3','2','test','again',now())MySQL Error: 1062 (Duplicate entry '3' for key 1)Session halted. Within mysql table called sky_member I have set member id to int(5) and there are currently 3 members with member_id as primary key with auto_increment 1,2,3 (1 for 1st member, 2 for second and so forth) table called sky_message The problem is there is a sky_message table with fields; to_id, from_id and msg_id. These values are conflicting with the member_id value within the sky_member table. Please help solve this one? I have attached screen shots of both tables mesageissues2.doc Quote Link to comment https://forums.phpfreaks.com/topic/281355-mysql-php-problem-reading-sent-messages/ Share on other sites More sharing options...
dogdaynoon Posted August 19, 2013 Share Posted August 19, 2013 (edited) this may be wrong path but do you have your to_id and from_id columns set to int? if you do, you don't need quotes around the number in the insert statement. Edited August 19, 2013 by dogdaynoon Quote Link to comment https://forums.phpfreaks.com/topic/281355-mysql-php-problem-reading-sent-messages/#findComment-1445886 Share on other sites More sharing options...
kicken Posted August 19, 2013 Share Posted August 19, 2013 You have your to_id and/or from_Id columns marked as being unique. You need to remove this constraint. Also, you posted in the form for Microsoft SQL Server, but you are using Mysql. They are completely different database packages. I've moved your thread for you, please pay attention to where you post in the future. Quote Link to comment https://forums.phpfreaks.com/topic/281355-mysql-php-problem-reading-sent-messages/#findComment-1445892 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.