Chapter 6. Working with Users, Page 123

Location on the page: 
top of the page
Chapter: 
6. Working with Users
Error: 

case 'insert':
// Record information for future lawsuit.
watchdog('user', t('User %user agreed to legal terms',
array('%user' => $user->name)));
break;

Correction: 

case 'insert':
// Record information for future lawsuit.
$name = $edit['name'];
watchdog('user', t('User %user agreed to legal terms',
array('%user' => $name)));
break;

Description of the Error: 

when operation insert happen, the user object is still loaded as anonymous, so $user->name get any information.
To get the new user's name you have to use the $edit variable who content the value submit by the new user in a array. So to get the name you have to use $edit['name'].