the red exclamation point is really only a warning, it means that DW cant properly inspect the code. If the page works in the browser, you can ignore it. Only if the page doesn't work in the browser should the exclamation mark be looked into.
that being said, you should be able to get rid of the exclamation mark by adding some blank spaces to the RepeatSelectionCounter_1_Iterations line. look carefully at the code i posted:
$RepeatSelectionCounter_1_Iterations = "".$imagesPerRow ."";
notice the two blank spaces between the $imagesPerRow variable and the end of the line " "";", these 2 blank spaces are important to helping DW inspect the code properly.
in the code you posted:
$RepeatSelectionCounter_1_Iterations = "".$imagesPerRow."";
those blank spaces are missing (yes, something that small can make that big of a difference)