You should not use:
$row = mysql_fetch_row($query);
extract($row);
mysql_fetch_row don't really gives you associated indexes, which is absolute necessity to extract the array you get.
If you're using extract, use this insted:
$row = mysql_fetch_assoc($query);
The better use of this extract if you add a prefix, with that you won't overwrite existing global variables.
If this is a joomla query, you should use $db->setQuery() AND
$row = $db->loadRow(); methods to retrieve the selected record.