Mandarin is the official standard. It is based on the dialect of Beijing.
So although they are supposed to, most Chinese people outside Beijing don't speak Mandarin in daily lives. But that doesn't mean they don't understand Mandarin. Learning Mandarin is required in most primary schools. Even if you didn't learn Mandarin formally at school, you always have all the TV and radio broadcasts around you, which are mostly in Mandarin.
Considering the pronunciational differences, there are numerous dialects in China. However, most dialects in northern China are quite similar to Mandarin, so the transition is not difficult.
But dialects like Cantonese, which is only used in areas like Guangdong and Hongkong, or the dialects spoken in Fujian Province and Taiwan are fairly different from Mandarin. That means those dialects are quite difficult, if not impossible, for people from other places to understand.
If you want everybody understand what you're saying, you'd better speak Mandarin. Althoug it doesen't matter If you only live in Cantonese spoken areas.