Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder mOrloff's Avatar
    Join Date
    Nov 2008
    Location
    The Great Pacific NW, USA
    Posts
    422
    Thanks
    8
    Thanked 6 Times in 6 Posts

    Update not successfull : why ??

    I am able to successfully run sqlsrv SELECT querys, but my UPDATE is returning false.

    Here's what I've got:
    PHP Code:
    $stockPN='TEST ITEM 2';
    $newDesc='UPDATE SUCCESSFUL';
    $updateSQL="UPDATE partrecord SET description=\'$newDesc\' WHERE fullpartnumber=\'$stockPN\' AND quantity>0";
    $update=sqlsrv_query($rzConn,$updateSQL); 
    echo 
    '<pre>';
    var_dump($update);
    echo 
    '</pre>'
    Am I doing something wrong ?
    ~ Mo
    Last edited by mOrloff; 03-23-2010 at 05:13 PM.

  • #2
    Senior Coder angst's Avatar
    Join Date
    Apr 2004
    Location
    Toronto, Ontario
    Posts
    2,114
    Thanks
    15
    Thanked 122 Times in 122 Posts
    try;

    PHP Code:
    $updateSQL="UPDATE partrecord SET description='" $newDesc "' WHERE fullpartnumber='" $stockPN "' AND quantity > 0"

  • #3
    Regular Coder mOrloff's Avatar
    Join Date
    Nov 2008
    Location
    The Great Pacific NW, USA
    Posts
    422
    Thanks
    8
    Thanked 6 Times in 6 Posts
    Thanks !
    That did it !!
    But ... why?
    Aren't those two options basically the same ??

    ~ Mo
    Last edited by mOrloff; 03-23-2010 at 06:03 PM.

  • #4
    Senior Coder angst's Avatar
    Join Date
    Apr 2004
    Location
    Toronto, Ontario
    Posts
    2,114
    Thanks
    15
    Thanked 122 Times in 122 Posts
    no, $newDesc is a string and should be wrapped in quotes, however you escaped the quotes which was causing the update to fail.


  •  

    Posting Permissions

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