or die() can only be used where you could test for a boolean but haven't used an if ().
In your case, $result = mysql_query($query) or die(mysql_error()); would return either false or a non false result so or die() will work correctly.
while () does not return a result. Therefore using or die() could never work properly there.
My helpful sig has gone because a mod below the administrator gave me an infraction - despite the administrator personally agreeing to it.
If you need any php tips or tricks you can PM me.