Jump to content

keep getting syntax error, cant figure out why :(


kendallkamikaze

Recommended Posts

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?

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

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

<?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>";
    }
}
?>

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

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

<?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>";
    }
}
?>

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.