"or die" should be a very very last resort. Normally you'd want your script to finish with a nice error message, or just skip the current operation.
instead of using "or die" try using an IF statement.
if ($result=mysql_query())
{
#query worked, be happy
}
else
{
Query did not work, be sad, send distress flare
mail (bla);
optional chickening out if this is a real bummer
exit;
};
You could turn this into a standard function to replace the mysql_query()
function my_sql_query($query,$die_on_error)
{
if ($result=mysql_query())
{
#query worked, be happy
return $result;
}
else
{
Query did not work, be sad, send distress flare
mail (bla);
# optional chickening out if this is a real bummer
if ($die_on_error)
{
exit;
};
};
};