mysql_fetch_array returns an array of the keys/values for one row from the query so using next() is not a solution.
what you may need to do is to read all the rows into an array
while ($row = mysql_fetch_array ($result))
{
$data[] = $row;
}
and then loop through the array using prev() and next() to compare values.
of course, if it's just one column you want to compare you can do that using your example.
$lastvalue = 0;
while ($row = mysql_fetch_array ($result))
{
$next_row = next($row);
if($row[field1]==$lastvalue);
do your stuff
$lastvalue=$row[field1];
}