Precedence:
($query = mysql_query($sql)) or ($variable = 1);
Remember to set $variable to something first, otherwise it won't be set if the query succeeds - and if you then try to use $variable you'd get an Undefined Variable notice.
Also, the first pair of parentheses isn't really necessary, but it makes it clearer what's going on.
If you want to be really clear about it, though...
if(!($query = mysql_query($sql)))
{
$variable = 1;
}