Can't update record

Question!

I'm trying to sync three scripts together to get cross domain profile editing working. The scripts are WordPress, BuddyPress, & JamRoom.

The code I'm using go to the test domain, get the profile's information from a php call that returns JSON, and then the JSON can be pushed to the WordPress/BuddyPress database.

The only problem is that I'm a front end developer wearing a backend's hat, so I'm learning as I go.

How can I check to see if the user_id already has entries under field_id (value 1 & 2) that have filled in values? And if that exists, simply update the entries. If it doesn't exist, simply create them.

Code I'm working with http://pastie.org/private/zivzakqyhzcbn3wkdfa6w

Columns I'm working with

id,field_id,user_id,"value","last_updated"

1,1,1,"admin","2011-03-07 00:35:52" 9,1,2,"YouRock","2011-03-07 01:11:32"



Answers

Assuming that id is key, use a ON DUPLICATE KEY UPDATE-statement

By : Dr.Molle


This video can help you solving your question :)
By: admin