[RESOLVED] Update on Duplicate Key Problem
Results 1 to 7 of 7

Thread: [RESOLVED] Update on Duplicate Key Problem

  1. #1
    Junior Member
    Join Date
    Mar 2012
    Posts
    11

    resolved [RESOLVED] Update on Duplicate Key Problem

    I have a problem with this code which I would like to insert a record into a table but if it already exists then update the existing record. This is my code so far:

    if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form4")) {
    $insertSQL = sprintf("INSERT INTO ProductsUpdated (Code, Web_Price, Overriden) VALUES (%s, %s, %s) ON DUPLICATE KEY UPDATE SET Web_Price=%s",
    GetSQLValueString($_POST['Code'], "text"),
    GetSQLValueString($_POST['Web_Price'], "text"),
    GetSQLValueString($_POST['Overriden'], "int")); <Line 53

    mysql_select_db($database_WebPriceUpdates, $WebPriceUpdates);
    $Result1 = mysql_query($insertSQL, $WebPriceUpdates) or die(mysql_error());

    I get the error message:

    Warning: sprintf() [function.sprintf]: Too few arguments in C:\wamp\www\Test.php on line 53

    Not sure what I am missing in this any help would be much appreciated.

  2. #2
    Pedantic Curmudgeon Weedpacket's Avatar
    Join Date
    Aug 2002
    Location
    General Systems Vehicle "Thrilled To Be Here"
    Posts
    21,842
    What it says: you have four "&#37;s" in your string, but only three arguments to fill them.
    THERE IS AS YET INSUFFICIENT DATA FOR A MEANINGFUL ANSWER
    FAQs! FAQs! FAQs! Most forums have them!
    Search - Debugging 101 - Collected Solutions - General Guidelines - Getting help at all

  3. #3
    Junior Member
    Join Date
    Mar 2012
    Posts
    11
    Just figured it out after I posted the thread, thanks for the reply

  4. #4
    Junior Member
    Join Date
    Sep 2012
    Posts
    2
    Hi

    I have been looking for a resolved to this myself. I am getting the same issue as you. May I ask please how you resolved this?

  5. #5
    Pna lbh ernq guvf¿
    Join Date
    Jul 2004
    Location
    Kansas City area
    Posts
    19,393
    Quote Originally Posted by manicsurfer View Post
    I have been looking for a resolved to this myself.
    Unless "this" happens to mean that you're using the exact same code as the OP above, you should create a new thread (rather than hijacking someone else's) and show us, at a minimum, a) the relevant part(s) of your code, and b) any and all error messages you're receiving (or a description of what's happening versus what you expected to happen).

  6. #6
    Junior Member
    Join Date
    Sep 2012
    Posts
    2

    Thank you

    Yes I am in fact using 'Exactly' the same code and strangely with a little more experimentation I too resolve it.

    However, thank you for you informative answer. It reminds me why I like 'Help' forums so much.

  7. #7
    Pna lbh ernq guvf¿
    Join Date
    Jul 2004
    Location
    Kansas City area
    Posts
    19,393
    Glad I could help!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •