mforan Posted November 29, 2006 Share Posted November 29, 2006 hi there, im having problems with this code:[color=blue]if ( (($buildchange[6] != "0") && ($buildchange[6] != "")) && ($info[8] == "Private")) ||(($buildchange[7] != "0") && ($buildchange[7] != "")) && ($info[8] == "Private") || ($info[8] == "Captain") || ($info[8] == "Major") || ($info[8] == "Lt. Colonel") || ($info[8] == "Colonel")) ||(($buildchange[8] != "0") && ($buildchange[8] != "")) && ($info[8] == "Private") || ($info[8] == "Captain") || ($info[8] == "Major") || ($info[8] == "Lt. Colonel") || ($info[8] == "Colonel") || ($info[8] == "Major General")) ||(($buildchange[9] != "0") && ($buildchange[9] != "")) && ($info[8] == "Private") || ($info[8] == "Captain") || ($info[8] == "Major") || ($info[8] == "Lt. Colonel") || ($info[8] == "Colonel")) || ($info[8] == "Major General")) || ($info[8] == "Lt. General")) ) {$done = false;$excuse = "Damn hacker, cant build those till you improve";} else {[/color]i keep getting the error: Parse error: parse error, unexpected T_BOOLEAN_ORcan anyone help here? Quote Link to comment Share on other sites More sharing options...
Psycho Posted November 29, 2006 Share Posted November 29, 2006 Wow, that's not exactly the easiest code to read through. Anyway at the end of the first [b]$info[8] == "Colonel"[/b] there are two right parens. The 2nd one closes the if conditional. In fact you have an extra right paren at the end of each line after that as well.By the way you could easily condense some of this. For example, you could change this:[code]if (($buildchange[6] != "0") && ($buildchange[6] != ""))[/code]To this:[code]if ($buildchange[6])[/code]Which means that the variable has a value and it is not false or 0. Quote Link to comment Share on other sites More sharing options...
btherl Posted November 30, 2006 Share Posted November 30, 2006 The problem here is your coding style.. it's terrible :)You can make things clearer with this technique:[code=php:0]$change6_bad = (($buildchange[6] != "0") && ($buildchange[6] != "")) && ($info[8] == "Private"));$change7_bad = (($buildchange[7] != "0") && ($buildchange[7] != "")) && ($info[8] == "Private") || ($info[8] == "Captain") || ($info[8] == "Major") || ($info[8] == "Lt. Colonel") || ($info[8] == "Colonel"));# and so on for each, thenif ($change6_bad || $change7_bad | ... ) {}[/code]You may want to split it up even more. One thing you could use is a "rank_greater_than()" function, instead of doing all those individual tests. That will make the code much clearer. And with clearer code, you will notice syntax errors much more easily.[code=php:0]if ((($buildchange[6] != "0") && ($buildchange[6] != "")) && !rank_greater_than($info[8], 'Private')) || ...[/code] Quote Link to comment Share on other sites More sharing options...
mforan Posted November 30, 2006 Author Share Posted November 30, 2006 yep yep yep, well i didnt program it you see. but i do agree it could be layed out a bit better.the guy that originally programmed it was ameteur his self i belive. much like my self!well thanks guys, using some of the things you said i got it working. cheers ;D Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.