Hi drewbie:
I guess I'm a WimpyCoder.
I've seen code constructions like yours often, but I'm not inclined to use it because I worry about the chances for failure. Seeing your problem and solution makes me think I'll stay away from it.
Specifically:
$query = mysql_query("SELECT * FROM login WHERE ID='$ID'", $link_id) || die ("Query failed :" . mysql_error());
This statement, it seems to me, might yield very different results depending on the order of parsing, and depending on what the parser considers a "TRUE" condition.
It's much cooler than the WimpyCode version I would write:
$query = mysql_query("SELECT * FROM login WHERE ID='$ID'", $link_id)
if (!$query) {die ("Query failed :" . mysql_error()); }
But I don't think the WimpyCode version would fail.
I'm asking here -- this ain't rhetorical -- in your collapsed version, is there ANY GUARANTEE that the parser will run the MySQL query before testing for TRUE condition? If it runs the DIE condition -- won't the parser find that condition TRUE?
I'm asking -- is there a downside to WimpyCode, other than that I'll be called a sissy? Is there an overhead my Wimpy way that I'm not considering?
I'd like to know. Until then, I am a complete wimp, writing explcit if conditionals to test the state of a var after running the code, instead of the all in one line approach favored by Macho Programmers.
I hate surprises, and your example problem encourages me to continue to be a WimpyCoder.