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]' "; 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'.......................... 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. Link to comment https://forums.phpfreaks.com/topic/198423-insert-on-duplicate/#findComment-1041790 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.