Why can't I connect to the internet on my iPhone 4? I've just bought an iPhone 4 and I want to connect to the internet but I can't do so.

Do I need an apple id to use an iPhone?

Definitely I've contacted my dataplan service and they are saying I should be able to connect to the internet now. But i can't!

I've waited over 3 weeks but still no internet. These are the messages i get from 1627:


  May 8, 2011 5:33 PM
  
  Dear Valued Customer, your GSM Mi
  World Mobile service has been
  activated as requested.
  
  Dear Valued Customer, your GSM Mi
  World Mobile service has been
  activated as requested.
  
  May 16, 2011 1:08 PM
  
  Thank you for re-contracting your M1
  line with IPHONE 4, 16GB, WHITE.
  Please call us at 1627 immediately if
  you did not subscribe to M1
  service(s).


I'm thinking there's something I need to do in settings but I don't know what.. Right now if i open safari it just won't connect.
No - you only need a correctly provisioned data plan and working iPhone software. There isn't much that you can mis-configure unless you jailbreak or start mucking with custom iPhone carrier settings profiles. 

iPhone data can break or be misconfigured on the carrier end - even if SMS and voice calls work, there can still be a problem with the data service so you may need to get help from your carrier that is providing your data access. It could also be a software issue and Apple is the best place to get that sorted.

Your question is basically how do I systematically troubleshoot iPhone data and/or teach myself how to operate my new phone. (no offense, but it's hard to determine from a one sentence question what your level of comfort is with iPhone data terms and how it may break.)

You might want to get some help from Apple or the carrier since the internet works as long as you are in working Wifi or your data plan is active on the iPhone. Troubleshooting an issue by back and forth on a discussion board is very hard so it's best to get real-time assistance when you are sitting in front of your computer to update the software if needed.

http://www.apple.com/support/iphone/ has some great getting started tips if you want to work through it yourself.

Specifically http://support.apple.com/kb/HT1976 documents the concepts and has an express lane link to get support directly from Apple to narrow down the cause - if 3G is showing in the menu bar it's not some obvious error or switch but something obscure or a carrier issue.