Update query NOT working

Discussion in 'Databases' started by zed420, Jan 2, 2009.

  1. #1
    Hi All
    Can anyone tell me why does this query give me '0' as an update of custname1 and NO change in 'pending field'instead of what I'm asking???
    If I take off "AND status1 = 'Pending' " bit, it works.
    Some help will be greatly appreciated.
    
    if($_GET['custname1']){
    $query = "UPDATE restHotel SET custname1 = '<b>Cancel</b>' AND status1 = 'Pending' 
    WHERE id ='$id'"; 
    $result = mysql_query($query)or die(mysql_error());
    ?><script>document.location.href='restDisplayAll.php'</script><?
    Code (markup):
    Thanks
    Zed
     
    zed420, Jan 2, 2009 IP
  2. devpedia

    devpedia Peon

    Messages:
    19
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Change your query to:
    
    $query = "UPDATE restHotel SET custname1 = '<b>Cancel</b>'
    WHERE id ='$id' AND status1 = 'Pending'"; 
    
    PHP:
     
    devpedia, Jan 2, 2009 IP
  3. zed420

    zed420 Member

    Messages:
    60
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #3
    Thanks for your quick reply, but It hasn't worked, its same as before if I take off the last bit off it works fine.

    thanks
    Zed
     
    zed420, Jan 2, 2009 IP
  4. devpedia

    devpedia Peon

    Messages:
    19
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Do you know what is this query logic?
    $query = "UPDATE restHotel SET custname1 = '<b>Cancel</b>'
    WHERE id ='$id' AND status1 = 'Pending'";

    This means update resHotel table, update field custname1 to Cancel, where id is $id and status1 is Pending.

    Check you database table if this field:
    status1 = 'Pending'
    is true or not?

    It should work.
     
    devpedia, Jan 2, 2009 IP
  5. zed420

    zed420 Member

    Messages:
    60
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #5
    Sorry Chuck, It was my School boy mistake instead of using AND it should've been a Comma
    Thank you
    Zed
     
    zed420, Jan 2, 2009 IP