Plug your iPhone in to iTunes and you'll be notofied that there's an update available...
iPhone OS 3.1.2 Software Update
This update contains bug fixes and improvements, including the following:
• Resolves sporadic issue that may cause iPhone to not wake from sleep • Resolves intermittent issue that may interrupt cellular network services until restart • Fixes bug that could cause occasional crash during video streaming
Products compatible with this software update: • iPhone • iPhone 3G • iPhone 3GS
Ironically, I've not suffered from any othese problems on my iPhone, iPhone 3G or iPhone 3GS.