Sometimes, rather than connecting to a known WiFi network, you will instead see an exclamation mark in front of the menubar symbol and an error message stating that connection is not possible as you have a self-assigned IP address.
To fix this issue, do this:
Turn the Airport OFF.
Go to System Preferences → Network → Advanced, select the network & click '-' to remove it.
Go to System Preferences → Security & Privacy and turn the Firewall OFF.
Go to Utilities and open Keychain; delete the network entry and then run Keychain First Aid from the main menu to repair it.
Go to Utilities, open Disk Utility and repair disk permissions.
OPTIONAL: if you have Bluetooth on or DropBox, turn these off as they may interfere with the process.
Now restart the computer...
Once logged back in, it should prompt you to join a network, select the one you've had issues with and enter it's password.
Then go to System Preferences → Network → Advanced and select the network, then click the 'TCP/IP' tab and keep pressing the 'Renew DHCP Lease' button until you get a new IP address (usually something like 10.0.x.x on an airport network and 192.168.x.x on other networks).
Once online, restart DropBox and Bluetooth as needed, and turn your Firewall back on.