Jump to content

Insert on duplicate


zimmo

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.