Thread: Updating users
View Single Post
Old 02-09-2008, 01:58 AM   #12 (permalink)
Salathe
Moderateur
RegEx Guru PHP Guru Top Contributor Advanced Programmer 
 
Salathe's Avatar
 
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
Salathe is on a distinguished road
Default

It'll make things infinitely easier for you if your code is laid out nicely and easier to read. Also the clauses in the query should go UPDATE, SET, WHERE, LIMIT; in that order. The WHERE clause should catch only a single row (assuming you check against a primary key column) but just in case the LIMIT is there to make sure only one row is affected.

PHP Code:
mysql_query(sprintf("
    UPDATE 
        users
    SET
        username = '%s',
        password = '%s',
        email    = '%s',
        access   = '%s',
        joindate = '%s',
    WHERE
        id = %d
    LIMIT 1
    ;"
,
    
mysql_real_escape_string($username),
    
mysql_real_escape_string($password),
    
mysql_real_escape_string($email),
    
mysql_real_escape_string($access),
    
mysql_real_escape_string($date),
    (int) 
$id
)) or die(mysql_error()); 
Salathe is offline  
Reply With Quote
The Following User Says Thank You to Salathe For This Useful Post:
Orc (02-09-2008)