kendallkamikaze Posted February 6, 2009 Share Posted February 6, 2009 so ive been fiddling with this for the last hour and cant figure out whats wrong or what im missing. When i get the syntax error to go away, the 'AcademyLevel' part doesnt function. <?php $AcademyLevel=$_GET['AcademyLevel']; $sql="SELECT * FROM player WHERE id='$id' and $AcademyLevel='AcademyLevel'"; $result=mysql_query($sql); while($r=mysql_fetch_array($result)) { $mStatus=$r['mod']; $mStatus=$r['Diamond']; $AcademyLevel=$r['AcademyLevel']; if ($mStatus=="mod" or $mStatus=="Diamond" and $AcademyLevel > 4) echo "<BR><TABLE WIDTH='400' class='b' CELLSPACING='1' CELLPADDING='5' border='0'><td><font size='2px'><B>Association Management Center</b></font><BR><center> <a href='association_create.php'> Create Your Association! </a></center> <td></table>"; } else { echo "<BR><TABLE WIDTH='400' class='b' CELLSPACING='1' CELLPADDING='5' border='0'><td><b><font size='2px'>Association Management Center</b><BR><center> You must pass Academy Level 5 before you can start an association and run shows. </font></center></td></table>"; } ?> any ideas? Quote Link to comment Share on other sites More sharing options...
Mark Baker Posted February 6, 2009 Share Posted February 6, 2009 Do you really mean: $sql="SELECT * FROM player WHERE id='$id' and $AcademyLevel='AcademyLevel'"; or $sql="SELECT * FROM player WHERE id='$id' and AcademyLevel='$AcademyLevel'"; Use || and && rather than "or" and "and" Missing { if ($mStatus=="mod" || $mStatus=="Diamond" && $AcademyLevel > 4) { And you might want to bracket to distinguish between (A || B) && C and A || (B && C) rather than relying on operator precedence Quote Link to comment Share on other sites More sharing options...
kendallkamikaze Posted February 6, 2009 Author Share Posted February 6, 2009 I did mean $sql="SELECT * FROM player WHERE id='$id' and AcademyLevel='$AcademyLevel'"; and i added the { but now im getting: Parse error: syntax error, unexpected $end in /home/collegh9/public_html/one-stride/player_diamond.php on line 156 which is the footer code: <?php include 'footer.php'; ?> i'm very new to PHP and im pretty much self teaching myself, and its obvious that im horrible at it lol Quote Link to comment Share on other sites More sharing options...
kendallkamikaze Posted February 6, 2009 Author Share Posted February 6, 2009 no ideas:(? Quote Link to comment Share on other sites More sharing options...
MatthewJ Posted February 6, 2009 Share Posted February 6, 2009 You're still missing the brace that would close the while loop so you have while () { if() { } else { } //Then nothing here to close the while statement Quote Link to comment Share on other sites More sharing options...
marcus Posted February 6, 2009 Share Posted February 6, 2009 <?php $AcademyLevel = $_GET['AcademyLevel']; $sql = "SELECT * FROM player WHERE id='$id' and $AcademyLevel='AcademyLevel'"; $result = mysql_query($sql); while ($r = mysql_fetch_array($result)) { $mStatus = $r['mod']; $mStatus = $r['Diamond']; $AcademyLevel = $r['AcademyLevel']; if ($mStatus == "mod" or $mStatus == "Diamond" and $AcademyLevel > 4) { echo "<BR><TABLE WIDTH='400' class='b' CELLSPACING='1' CELLPADDING='5' border='0'><td><font size='2px'><B>Association Management Center</b></font><BR><center> <a href='association_create.php'> Create Your Association! </a></center> <td></table>"; } else { echo "<BR><TABLE WIDTH='400' class='b' CELLSPACING='1' CELLPADDING='5' border='0'><td><b><font size='2px'>Association Management Center</b><BR><center> You must pass Academy Level 5 before you can start an association and run shows. </font></center></td></table>"; } } ?> Quote Link to comment Share on other sites More sharing options...
kendallkamikaze Posted February 6, 2009 Author Share Posted February 6, 2009 Alright so things are almost functioning but <?php $AcademyLevel = $_GET['AcademyLevel']; $sql = "SELECT * FROM player WHERE id='$id' and $AcademyLevel='AcademyLevel'"; $result = mysql_query($sql); while ($r = mysql_fetch_array($result)) { $mStatus = $r['mod']; $mStatus = $r['Diamond']; $AcademyLevel = $r['AcademyLevel']; if ($mStatus == "mod" or $mStatus == "Diamond" and $AcademyLevel > 4) { echo "<BR><TABLE WIDTH='400' class='b' CELLSPACING='1' CELLPADDING='5' border='0'><td><font size='2px'><B>Association Management Center</b></font><BR><center> <a href='association_create.php'> Create Your Association! </a></center> <td></table>"; } else { echo "<BR><TABLE WIDTH='400' class='b' CELLSPACING='1' CELLPADDING='5' border='0'><td><b><font size='2px'>Association Management Center</b><BR><center> You must pass Academy Level 5 before you can start an association and run shows. </font></center></td></table>"; } } ?> Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/collegh9/public_html/one-stride/player_diamond.php on line 98 line 98 is - while ($r = mysql_fetch_array($result)) { EDIT: nvm on line 98 thing...but for some reason when youre under level 5 its not printing the 'you must be level 5' and when youre over level 5, its not printing the 'manage association' link Quote Link to comment Share on other sites More sharing options...
peranha Posted February 6, 2009 Share Posted February 6, 2009 This query is not correct. what is the $ for in from of Academylevel, is it supposed to be after the = to sign? SELECT * FROM player WHERE id='$id' and $AcademyLevel='AcademyLevel' Quote Link to comment Share on other sites More sharing options...
marcus Posted February 6, 2009 Share Posted February 6, 2009 You should be using mysql_error on your query executions. $result = mysql_query($sql) or die(mysql_error()); Quote Link to comment Share on other sites More sharing options...
kendallkamikaze Posted February 6, 2009 Author Share Posted February 6, 2009 This query is not correct. what is the $ for in from of Academylevel, is it supposed to be after the = to sign? SELECT * FROM player WHERE id='$id' and $AcademyLevel='AcademyLevel' i fixed that part and now all the errors are gone, but its still not printing antyhing if youre under level 5 or above level 5 Quote Link to comment Share on other sites More sharing options...
marcus Posted February 6, 2009 Share Posted February 6, 2009 Try this: $r = mysql_fetch_array($result); echo "<pre>",print_r($r),"</pre>"; See if your results are what you want them to be. Quote Link to comment Share on other sites More sharing options...
kendallkamikaze Posted February 6, 2009 Author Share Posted February 6, 2009 Try this: $r = mysql_fetch_array($result); echo "<pre>",print_r($r),"</pre>"; See if your results are what you want them to be. that for some reason just print the number 1 Quote Link to comment Share on other sites More sharing options...
kendallkamikaze Posted February 6, 2009 Author Share Posted February 6, 2009 repost, oops. Quote Link to comment Share on other sites More sharing options...
kendallkamikaze Posted February 6, 2009 Author Share Posted February 6, 2009 <?php $AcademyLevel = $_GET['AcademyLevel']; $sql = "SELECT * FROM player WHERE id='$id' and AcademyLevel='$AcademyLevel'"; $result = mysql_query($sql) or die(mysql_error()); $r = mysql_fetch_array($result); while ($r = mysql_fetch_array($result)) { $mStatus = $r['mod']; $mStatus = $r['Diamond']; $AcademyLevel = $r['AcademyLevel']; if ($mStatus == "mod" or $mStatus == "Diamond" and $AcademyLevel > 4) { echo "<BR><TABLE WIDTH='400' class='b' CELLSPACING='1' CELLPADDING='5' border='0'><td><font size='2px'><B>Association Management Center</b></font><BR><center> <a href='association_create.php'> Create Your Association! </a></center> <td></table>"; } else { echo "<BR><TABLE WIDTH='400' class='b' CELLSPACING='1' CELLPADDING='5' border='0'><td><b><font size='2px'>Association Management Center</b><BR><center> You must pass Academy Level 5 before you can start an association and run shows. </font></center></td></table>"; } } ?> Quote Link to comment Share on other sites More sharing options...
Mark Baker Posted February 6, 2009 Share Posted February 6, 2009 Repeating myself here Use || and && rather than "or" and "and" if ($mStatus=="mod" || $mStatus=="Diamond" && $AcademyLevel > 4) { And you might want to bracket to distinguish between (A || B) && C and A || (B && C) rather than relying on operator precedence 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.