What you are actually doing is a logical "or" check on each statement on either side of the "or". However, because of the left-to-right way PHP does the checking, if the first statement evaluates as true, then it does not bother to execute the expression on the right since it knows that in an "or" condition, if either value is true then the whole expression is true. But, if the first command evaluates as false (e.g.: if the "mysql_connect()" returns a FALSE result when it fails), then it proceeds to execute and evaluate the command on the right side of the "or", as it now needs to know its result to properly evaluate the entire or condition.
You could actually invert the logic using "and". In this case, the second statement would only be executed if the first statement evaluated as true (since if the first statement failed it would not matter if the second evaluated as true or false, as both must be true for an "and" condition to be true):
mysql_connect($a1, $a2, $a3) and echo "Hey, it worked!";
"and" and "or" are normally used for this sort of shorthand instead of the && and || logical operators, as the "word" versions have lower operator precedence than the symbol versions, making them evaluate after any other operators in the compared expressions have been evaluated.
PS: And I suppose you could get more complicated:
(mysql_connect($a1, $a2, $a3) and print("Hey, it worked!")) or die("Uh-oh!);