Check the drives cable connections. (PC only, cant do this in a laptop)
If the drive only recognizes a 'known good' CD intermittently, then replace the drive.
If the drive only reconizes certain CD's and not others consistently then it may be the format of the unrecognized CD's that is the problem. Again this may be rectified by upgrading the CDROM drive.