Where to add a widget class?

I copied the class definition and register_widget( 'My_Widget' ); to my theme’s functions.php file & it did show My Widget under Appearance > Widgets. So please place this code directly in your theme’s functions.php file. It is not recommended to edit anything in wp-includes directory.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)