SQL,PHP gurus! Help

Discussion in 'OT Technology' started by kevlarface, Jan 29, 2005.

  1. kevlarface

    kevlarface New Member

    Joined:
    Sep 17, 2002
    Messages:
    2,042
    Likes Received:
    0
    Location:
    Peg City
    I am trying to do an UPDATE

    here is my sql query

    $query = "UPDATE CondoTable
    SET city = '$city',
    address = '$address'
    WHERE id = '$id'";

    $results = mysql_query ($query);

    does that look correct?
     
  2. skooter

    skooter Guest

  3. 5Gen_Prelude

    5Gen_Prelude There might not be an "I" in the word "Team", but

    Joined:
    Mar 14, 2000
    Messages:
    14,519
    Likes Received:
    1
    Location:
    Vancouver, BC, CANADA
    If ID is numeric, you should lose the apostropies
     
  4. kevlarface

    kevlarface New Member

    Joined:
    Sep 17, 2002
    Messages:
    2,042
    Likes Received:
    0
    Location:
    Peg City
    skooter - thanks gonnna try it out

    5Gen_Prelude - I dropped the apostropies I am still getting no update but thanks anyways


    heres the update of my query :

    $mysql_query = "UPDATE CondoTable
    SET city = '$city',
    address = '$address'
    WHERE id = $id";

    mysql_query($mysql_query)
    or die('Update of table failed.');

    My id is the Primary key does that need any additional syntax?
     
  5. 5Gen_Prelude

    5Gen_Prelude There might not be an "I" in the word "Team", but

    Joined:
    Mar 14, 2000
    Messages:
    14,519
    Likes Received:
    1
    Location:
    Vancouver, BC, CANADA
    Swap the last " and ; ?

    I mean the first test I would try is to hardcode some values and try running the SQL query - that will tell you whether or not you have a mysql execution problem, or a syntax error.
     
    Last edited: Jan 30, 2005
  6. intrktevo

    intrktevo New Member

    Joined:
    Oct 18, 2004
    Messages:
    5,781
    Likes Received:
    0
    Location:
    UCF
    print out the query and see what values are being used, $id might not be set to anything causing it not to update
     
  7. Dark-Hawk

    Dark-Hawk New Member

    Joined:
    Nov 28, 2003
    Messages:
    347
    Likes Received:
    0
    Location:
    Connecticut
    Try this:
    Code:
    echo $city;
    echo $address;
    echo $id;
     
    $mysql_query = "UPDATE CondoTable
    SET city = '$city',
    address = '$address'
    WHERE id = $id"; 
    
    mysql_query($mysql_query)
    or die('Update of table failed.');
    
     

Share This Page