Using a variable outside of the while loop (scope)
You could try to define the variable before the loop, e.g.
$report = "";
while ($row = mysql_fetch_array($result)) {
$report .= "a"."b".$row["prevDOCid"]+1;
}
echo $report;
I hope this helps you!
Edit Use .= not +=