genista Posted November 19, 2006 Share Posted November 19, 2006 Hi,Nice and simple one but still causing me issues!I want to change this query:[code=php:0]$query = "INSERT INTO supplierimages (image1, supplierid) VALUES ('$image1','$supplierid')";[/code]to UPDATE instead. The reason for this is I keep getting duplicate entry errors for the supplierid if it already exists in the database.I won't embaress myself by posting my attempts to update, please help!Thanks,G Quote Link to comment Share on other sites More sharing options...
printf Posted November 19, 2006 Share Posted November 19, 2006 Add a condition to the INSERT![code]$query = "INSERT INTO supplierimages (image1, supplierid) VALUES('" . $image1 . "', '" . $supplierid . "') ON DUPLICATE KEY UPDATE image1 = '" . $image1 . "';[/code]printf Quote Link to comment Share on other sites More sharing options...
genista Posted November 19, 2006 Author Share Posted November 19, 2006 Great worked a treat!Thanks,G Quote Link to comment Share on other sites More sharing options...
fenway Posted November 19, 2006 Share Posted November 19, 2006 This is of course contigent on an appopriate unique index. Quote Link to comment 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.