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 3 of 3

Thread: cannot update

  1. #1
    dea
    dea is offline
    New to the CF scene
    Join Date
    Jan 2007
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    cannot update

    attn: memb_id is primary key and indicate member's email address.

    In the middle coding i also insert those data need to be update.

    Below are the code most suspect:

    $query="UPDATE member SET
    username='{$_POST['username']}', password='{$_POST['password']}',
    phone_no='{$_POST['phone_no']}',
    month='{$_POST['month']}',
    day='{$_POST['day']}',
    year='{$_POST['year']}',
    WHERE memb_id='{$_POST['memb_id']}' ";

    if(is_numeric($_GET['memb_id'])){

    $query="SELECT * FROM member WHERE memb_id={$_GET['memb_id']}";

    if($r=mysql_query($query)){

    $row=mysql_fetch_array($r);

    echo "<form action='editProfile.php' method='POST'>

    <input type='hidden' name='memb_id' value=".$_GET['memb_id'].">
    <input type='submit' name='save' value='Save'>
    <input type='submit' name='cancel' value='Cancel'>

    }else{
    print 'Could not retrieve the record because:<b>'.mysql_error().'</b>. </p>';
    }


    }

    else{
    print'<p><b>You must have made a mistake in using this page.</b></p>';
    }

  • #2
    Senior Coder koyama's Avatar
    Join Date
    Dec 2006
    Location
    Copenhagen, Denmark
    Posts
    1,246
    Thanks
    1
    Thanked 5 Times in 5 Posts
    Looks like there is a comma that shouldn't be there:

    Code:
    $query="UPDATE member SET
    username='{$_POST['username']}', password='{$_POST['password']}',
    phone_no='{$_POST['phone_no']}',
    month='{$_POST['month']}',
    day='{$_POST['day']}',
    year='{$_POST['year']}',  <<<---- 
    WHERE memb_id='{$_POST['memb_id']}' ";
    What error message do you get?

  • #3
    Senior Coder Mhtml's Avatar
    Join Date
    Jun 2002
    Location
    Sydney, Australia
    Posts
    3,531
    Thanks
    0
    Thanked 1 Time in 1 Post
    Good thing to keep in mind too, is always dump your $query so you can examine what's being put in it... Half the time you'll find you've forgotten something or passed the wrong value.
    Omnis mico antequam dominus Spookster!


  •  

    Posting Permissions

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