zimmo Posted April 13, 2010 Share Posted April 13, 2010 I am not sure if my mysql query is correct. If you look at the code below you will see. I have never done this kind of update before and its exactly what I need. $SQL = " INSERT INTO fishery_b_details (fishery_id, venue_name, primary_contact, address_1, address_2, address_3, town, county, postcode, email, telephone_1, telephone_2, fax) VALUES (fishery_id = '$_SESSION[fishery_id]', venue_name = '$_SESSION[venue_name]', primary_contact = '$_POST[primary_contact]', address_1 = '$_POST[address_1]', address_2 = '$_POST[address_2]', address_3 = '$_POST[address_3]', town = '$_POST[town]', county = '$_POST[county]', postcode = '$_POST[postcode]', email = '$_POST[email]', telephone_1 = '$_POST[telephone_1]', telephone_2 = '$_POST[telephone_2]', fax = '$_POST[fax]') ON DUPLICATE KEY UPDATE fishery_id = '$_SESSION[fishery_id]', venue_name = '$_SESSION[venue_name]', primary_contact = '$_POST[primary_contact]', address_1 = '$_POST[address_1]', address_2 = '$_POST[address_2]', address_3 = '$_POST[address_3]', town = '$_POST[town]', county = '$_POST[county]', postcode = '$_POST[postcode]', email = '$_POST[email]', telephone_1 = '$_POST[telephone_1]', telephone_2 = '$_POST[telephone_2]', fax = '$_POST[fax]' "; Quote Link to comment https://forums.phpfreaks.com/topic/198423-insert-on-duplicate/ Share on other sites More sharing options...
JustLikeIcarus Posted April 14, 2010 Share Posted April 14, 2010 Here is an example of what you need to change the code to. hope it makes sense. $fishery_id = $_SESSION[fishery_id]; $venue_name = $_SESSION[venue_name]; etc............. $SQL = "INSERT INTO fishery_b_details (fishery_id, venue_name, primary_contact, address_1, address_2, address_3, town, county, postcode, email, telephone_1, telephone_2, fax) VALUES ('$fishery_id', '$venue_name'.......................... Quote Link to comment https://forums.phpfreaks.com/topic/198423-insert-on-duplicate/#findComment-1041776 Share on other sites More sharing options...
Ken2k7 Posted April 14, 2010 Share Posted April 14, 2010 Not really an INSERT ON DUPLICATE if you forgot the DUPLICATE part. Quote Link to comment https://forums.phpfreaks.com/topic/198423-insert-on-duplicate/#findComment-1041790 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.