You should ONLY use the code that's on the laptop. Using your friends code is not allowed.
You may have the wrong code for the type of CD you have. If you've got a label on a laptop it's an OEM version of XP - if the CD is a retail version, then it won't work.
However if you've tried your friends CD and code - then they should at least be valid together.
It's very easy to misread the codes printed on the labels on equipment - 8 and B look very similar in the font they use. So double check everything.