When you buy a new controller, you need to associate (or "pair it") it with you PlayStation 3 before you can use it to play games. To do this, turn on your PlayStation 3 and attach the USB cable between the console and the controller. Pressing the PS button will pair the controller with the PS3. You can test the pairing by trying to navigate the XMB.
If this process does not work, you can use a paper clip to press the reset button on the back of the controller (it’s located near the upper-right side of the label). Also, make sure the controller has been charged.