I think you may need to use setAttr rather than saying pSphere1.translateX.
so
setAttr pShere1.tx $cube1Xpos;
setAttr pShere1.ty $cube1Ypos;
setAttr pShere1.tz $cube1Zpos;
try that, is this an expression or a script? cause that will make a difference to your syntax.
Post again if you need more help
Alan
Technical Director - Framestore
Currently working on: Your Highness
IMDB