Hello all,

I have this bit of code in my session handler function and I am wanting to write this data to the unique 'id' all get in my 'users' table. Nevermind about why I want to store that info there...

Upon successful login, the 'id' is returned from db and inserted into $_SESSION['id']. In this sprintf code below I want to use that current 'id' for the where detail. Toss me a bone please?

Thanks! 🙂

	$q = sprintf('REPLACE INTO users (sess_id, data) VALUES ("%s", "%s") where id="%s"', mysqli_real_escape_string($db, $sess_id), mysqli_real_escape_string($db, $data), mysqli_real_escape_string($db, $id)); 

(Changed [noparse]

 tags to [code=php] tags[/noparse]. -- MOD.)[/color][/i]

--------------------------
OSX 10.5.3, PHP 5.2.5, MySQL 5.0.45

    If the id column is an integer, then I would change it to:

    $q = sprintf(
       "REPLACE INTO users (sess_id, data) VALUES ('%s', '%s') where id=%d",
       mysqli_real_escape_string($db, $sess_id),
       mysqli_real_escape_string($db, $data),
       (int)$id
    );
    
      Write a Reply...