My iphone is behaving strangely for past few days.

It reboots when I try to switch it off. I just cannot switch it off. Also, I get the message "This accessory is not made to work with the iphone". Sometimes, the click sounds randomly disappear.

Any clues. Is it a software or hardware issue. I am using 3.0.1.

Thanks