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? Link to comment https://forums.phpfreaks.com/topic/143992-keep-getting-syntax-error-cant-figure-out-why/ 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 Link to comment https://forums.phpfreaks.com/topic/143992-keep-getting-syntax-error-cant-figure-out-why/#findComment-755550 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 Link to comment https://forums.phpfreaks.com/topic/143992-keep-getting-syntax-error-cant-figure-out-why/#findComment-755551 Share on other sites More sharing options...
kendallkamikaze Posted February 6, 2009 Author Share Posted February 6, 2009 no ideas:(? Link to comment https://forums.phpfreaks.com/topic/143992-keep-getting-syntax-error-cant-figure-out-why/#findComment-755563 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 Link to comment https://forums.phpfreaks.com/topic/143992-keep-getting-syntax-error-cant-figure-out-why/#findComment-755572 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>"; } } ?> Link to comment https://forums.phpfreaks.com/topic/143992-keep-getting-syntax-error-cant-figure-out-why/#findComment-755576 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 Link to comment https://forums.phpfreaks.com/topic/143992-keep-getting-syntax-error-cant-figure-out-why/#findComment-755579 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' Link to comment https://forums.phpfreaks.com/topic/143992-keep-getting-syntax-error-cant-figure-out-why/#findComment-755582 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()); Link to comment https://forums.phpfreaks.com/topic/143992-keep-getting-syntax-error-cant-figure-out-why/#findComment-755583 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 Link to comment https://forums.phpfreaks.com/topic/143992-keep-getting-syntax-error-cant-figure-out-why/#findComment-755584 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. Link to comment https://forums.phpfreaks.com/topic/143992-keep-getting-syntax-error-cant-figure-out-why/#findComment-755587 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 Link to comment https://forums.phpfreaks.com/topic/143992-keep-getting-syntax-error-cant-figure-out-why/#findComment-755592 Share on other sites More sharing options...
kendallkamikaze Posted February 6, 2009 Author Share Posted February 6, 2009 repost, oops. Link to comment https://forums.phpfreaks.com/topic/143992-keep-getting-syntax-error-cant-figure-out-why/#findComment-755594 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>"; } } ?> Link to comment https://forums.phpfreaks.com/topic/143992-keep-getting-syntax-error-cant-figure-out-why/#findComment-755622 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 Link to comment https://forums.phpfreaks.com/topic/143992-keep-getting-syntax-error-cant-figure-out-why/#findComment-755774 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.