SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Thread: Where ID help.

  1. #1
    SitePoint Member XtraElusive's Avatar
    Join Date
    Jul 2003
    Location
    CA
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Angry Where ID help.

    I have an 'Edit User Details Section'. It has the values filled out that it get's from the 'user list' page and everything, but when i go to update t says.
    "Error updating user details: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE ID=''' at line 8"

    I copied the example from the code archive and modified it to look like what i wanted.

    /*$cnx = mysql_connect('localhost', 'root', 'mypasswd');
    mysql_select_db('users');

    if (isset($_POST['edit'])):


    $id = $_GET['id']; //IS THIS RIGHT?get it from prev.page.
    $un = $_POST['un'];
    $rd = $_POST['rd'];
    $fn = $_POST['fn'];
    $ln = $_POST['ln'];
    $email = $_POST['email'];
    $pass = $_POST['pass'];

    $sql = "UPDATE users SET
    Username='$un',
    RegDate='$rd',
    Firstname='$fn',
    Lastname='$ln',
    Email='$email',
    Password='$pass',
    WHERE ID='$id'"; ///IT ERRORS HERE.
    if (@mysql_query($sql)) {
    echo('<p>User details updated.</p>');
    } else {
    echo('<p>Error updating user details: ' .
    mysql_error() . '</p>');
    }*/

    it errors at teh WHERE ID part, what's wrong?

  2. #2
    Romans 12:2 codyrockx's Avatar
    Join Date
    Jul 2003
    Location
    Newberg, Oregon
    Posts
    422
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    well, im not sure but check to make sure that the ID column is spelled like u have it in the script. that might be it.

  3. #3
    SitePoint Member XtraElusive's Avatar
    Join Date
    Jul 2003
    Location
    CA
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I made them all the same etc, didn't work, but thx for input.

  4. #4
    SitePoint Addict Viral's Avatar
    Join Date
    Nov 2001
    Location
    Washington DC
    Posts
    294
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    GET means you are passing the id value in the query string, like this: http://www.yoursite.com/page.php?id=2

    I doubt you're doing this. It would be extremely insecure. If you are passing it in the form (as a hidden field, for example) switch that one line to $id = $_POST['id'];

    --Viral
    A computer without Windows is like a chocolate cake without mustard.

  5. #5
    SitePoint Member XtraElusive's Avatar
    Join Date
    Jul 2003
    Location
    CA
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Nevermind, i fixed, it, and it was a stupid , <- comma that i put after the line b4 the where id area..


Bookmarks

Posting Permissions

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