When you're dynamically generating your points, you might try setting
the index values with the set() function, like this:
$shp->set('index', $i);
The member properties aren't always directly accessible, so the set
function should be used in php mapscript.
Might fix your problem.
-Camden