Unable to Display info

Discussion in 'PHP / Perl / Ruby on Rails' started by steven21, Aug 1, 2007.

  1. steven21 Ice Hockey Know All

    PHP:
    <?php global $no_of_players;

    if (
    $act==Goals) { $sort=1$display=$act; } elseif ($act==Assists) { $sort=1$display=$act; } elseif ($act==Games) { $sort=1;  $display="Appearances"; } elseif ($act==PIM) { $sort=1$display=$act; } elseif ($act==Points) { $sort=1$display=$act;} elseif ($act==GoalsAgainst) { $sort=1$display="Goals Conceded"$g=1;}  elseif ($act==Shots) { $sort=1$display="Shots Against"$g=1; }  elseif ($act==SavePercentage) { $sort=1$display="Save Percentage"$sp=1$g=1;} elseif ($act==ShutOuts) { $sort=1;  $display=$act; } else { $sort=""; }



    if (
    $sort !=0) {
    if (
    $g !=0) {
    // Goalie
    echo ("$display </p>
    <table width=\"350\" border=\"0\" align=\"center\">
    <tr><td width=\"175\" bgcolor=\"#E7BD1D\"><span class=\"style13\"><strong>Goalie</strong></span></td>
    <td width=\"100\" bgcolor=\"#E7BD1D\"><div align=\"center\" class=\"style13\"><strong>Team</strong></div></td>
    <td width=\"75\"bgcolor=\"#E7BD1D\"><div align=\"center\" class=\"style13\"><strong>$act</strong></div></td></tr>"
    );
        
    $count 1;
        
        if (
    $sp!=0) {
        
    $query "SELECT *, IF( Shots = 0, 0,  Shots-GoalsAgainst / Shots ) as save_percentage FROM `snl_goalies` ORDER BY $act desc LIMIT $no_of_players";
        
    $result mysql_query($query) or die ('Unable to show players');
            while ( 
    $rows mysql_fetch_array($result) ) {
            
    $Goalie $rows['Goalie'];
            
    $Shots $rows['Shots'];
            
    $GoalsAgainst $rows['GoalsAgainst'];
            
    $ShutOuts $rows['ShutOuts'];
            
    $TeamID $rows['TeamID'];
            
            if (
    $Shots || $GoalsAgainst == "") {
            
    $Stat1 $Shots-$GoalsAgainst;
            
    $Stat $Stat1 $Shots;
            
    $Stat number_format($Stat2);
            } else { 
    $Stat "0";     }
            
            
    $query1 "SELECT * FROM `teams` WHERE `TeamID` = '$TeamID'";
            
    $result1 mysql_query($query1) or die ('Unable to show players');
            
    $rows1 mysql_fetch_array($result1);
            
    $TeamName $rows1['ShortName'];
            
                if(
    $count%2){
                echo (
    "<tr><td bgcolor=\"#FFFFFF\"><span class=\"style18\">$Goalie</span></td> <td bgcolor=\"#FFFFFF\"><div      align=\"center\" class=\"style18\"><a href=\"TeamStats.php?TeamID=$TeamID\">$TeamName</a></div></td><td bgcolor=\"#FFFFFF\"><div align=\"center\" class=\"style18\">$Stat</div></td></tr>"); $count++; }
            else {
                echo (
    "<tr><td bgcolor=\"#EEEEEE\"><span class=\"style18\">$Goalie</span></td> <td bgcolor=\"#EEEEEE\"><div align=\"center\" class=\"style18\"><a href=\"TeamStats.php?TeamID=$TeamID\">$TeamName</a></div></td><td bgcolor=\"#EEEEEE\"><div align=\"center\" class=\"style18\">$Stat</div></td> </tr>"); $count++; } }
         echo (
    "</table></p><p class=\"style18\"><a href=\"snlplayers.php\">< Back to top players</a>");
            
        } else {
        
    $query "SELECT * FROM `snl_goalies` ORDER BY $act desc LIMIT $no_of_players";
        
    $result mysql_query($query) or die ('Unable to show players');
            while ( 
    $rows mysql_fetch_array($result) ) {
            
    $Goalie $rows['Goalie'];
            
    $Stat $rows["$act"];
            
    $TeamID $rows['TeamID'];
                    
            
    $query1 "SELECT * FROM `teams` WHERE `TeamID` = '$TeamID'";
            
    $result1 mysql_query($query1) or die ('Unable to show players');
            
    $rows1 mysql_fetch_array($result1);
            
    $TeamName $rows1['ShortName'];
            
                if(
    $count%2){
                echo (
    "<tr><td bgcolor=\"#FFFFFF\"><span class=\"style18\">$Goalie</span></td> <td bgcolor=\"#FFFFFF\"><div      align=\"center\" class=\"style18\"><a href=\"TeamStats.php?TeamID=$TeamID\">$TeamName</a></div></td><td bgcolor=\"#FFFFFF\"><div align=\"center\" class=\"style18\">$Stat</div></td></tr>"); $count++; }
            else {
                echo (
    "<tr><td bgcolor=\"#EEEEEE\"><span class=\"style18\">$Goalie</span></td> <td bgcolor=\"#EEEEEE\"><div align=\"center\" class=\"style18\"><a href=\"TeamStats.php?TeamID=$TeamID\">$TeamName</a></div></td><td bgcolor=\"#EEEEEE\"><div align=\"center\" class=\"style18\">$Stat</div></td> </tr>"); $count++; } }
         echo (
    "</table></p><p class=\"style18\"><a href=\"snlplayers.php\">< Back to top players</a>");
         }
    } else {
        
    // regular player
        
    echo ("$act </p>
        <table width=\"350\" border=\"0\" align=\"center\">
        <tr> <td width=\"175\" bgcolor=\"#E7BD1D\"><span class=\"style18\"><strong>Player</strong></span></td>
        <td width=\"100\" bgcolor=\"#E7BD1D\"><div align=\"center\" class=\"style18\"><strong>Team</strong></div></td>
        <td width=\"75\"bgcolor=\"#E7BD1D\"><div align=\"center\" class=\"style18\"><strong>$act</strong></div></td></tr>"
    );
        
        
    $count 1;
        
    $query "SELECT * FROM `snl_players` ORDER BY $act desc LIMIT $no_of_players";
        
    $result mysql_query($query) or die ('Unable to show players');
            while ( 
    $rows mysql_fetch_array($result) ) {
            
    $Player $rows['Player'];
            
    $Stat $rows["$act"];
            
    $TeamID $rows['TeamID'];
                    
            
    $query1 "SELECT * FROM `teams` WHERE `TeamID` = '$TeamID'";
            
    $result1 mysql_query($query1) or die ('Unable to show players');
            
    $rows1 mysql_fetch_array($result1);
            
    $TeamName $rows1['ShortName'];
            
                if(
    $count%2){
                echo (
    "<tr><td bgcolor=\"#FFFFFF\"><span class=\"style18\">$Player</span></td> <td bgcolor=\"#FFFFFF\"><div      align=\"center\" class=\"style18\"><a href=\"TeamStats.php?TeamID=$TeamID\">$TeamName</a></div></td><td bgcolor=\"#FFFFFF\"><div align=\"center\" class=\"style18\">$Stat</div></td></tr>"); $count++; }
            else {
                echo (
    "<tr><td bgcolor=\"#EEEEEE\"><span class=\"style18\">$Player</span></td> <td bgcolor=\"#EEEEEE\"><div align=\"center\" class=\"style18\"><a href=\"TeamStats.php?TeamID=$TeamID\">$TeamName</a></div></td><td bgcolor=\"#EEEEEE\"><div align=\"center\" class=\"style18\">$Stat</div></td> </tr>"); $count++; } }
         echo (
    "</table></p><p class=\"style18\"><a href=\"snlplayers.php\"> < Back to top players</a>");
         }
         
    } else {      
    // show available sorts
         
    include ('snl_players_list.php');
         }
         
         
         
    ?>
    I am trying to get the following page http://www.fifeflyers.co.uk/snlplayers.php to display the 'Shut Outs' info but when you click on it, I get the message Unable to show players I was wondering if anyone could see what's wrong with the code?

    I cant see it, been looking at it too long now.
  2. Andrew Taylor CS New Media Staff

    Best way to start would be to change all of the "or die" messages

    Change them to "Unable to show players1", "Unable to show players2" etc.

    That way you'll know which query is failing

    If you send me a ticket with the login details, I'll have a look at the database etc. for you
  3. Nick Irvine Secretly the main man

    Changing the error messages is a good place to start. If you still havent sorted it let me know. I think thats my code?
  4. steven21 Ice Hockey Know All

    Ok, from the 1st "Unable to show player" I have labelled them 1 - 6, and it is the 5th one that gives me the error - unable to show players5.

    It is Nick, I have finally got round to trying to add the shut outs to the list. lol
  5. Andrew Taylor CS New Media Staff

    You don't seem to have a field in the database called ShutOuts, so the order by part isn't working
  6. steven21 Ice Hockey Know All

    I have checked and double checked that ShutOuts is in my database, even double checked my spelling, it is definitely there - does the order of the D/B matter?
  7. Andrew Taylor CS New Media Staff

    I can't see a field called ShutOuts in snl_players, only in snl_goalies
  8. steven21 Ice Hockey Know All

    it shouldn't be in the players, it is for the goalies. hmm?
  9. Andrew Taylor CS New Media Staff

    Is this query 5?

    PHP:
        $query "SELECT * FROM `snl_players` ORDER BY $act desc LIMIT $no_of_players";
        
    $result mysql_query($query) or die ('Unable to show players');
  10. steven21 Ice Hockey Know All

    I am not sure of the order to be honest. just trying to have a look the now
  11. Andrew Taylor CS New Media Staff

    Try replacing the top line with this:

    PHP:
    if ($act==Goals) { $sort=1$display=$act; } elseif ($act==Assists) { $sort=1$display=$act; } elseif ($act==Games) { $sort=1;  $display="Appearances"; } elseif ($act==PIM) { $sort=1$display=$act; } elseif ($act==Points) { $sort=1$display=$act;} elseif ($act==GoalsAgainst) { $sort=1$display="Goals Conceded"$g=1;}  elseif ($act==Shots) { $sort=1$display="Shots Against"$g=1; }  elseif ($act==SavePercentage) { $sort=1$display="Save Percentage"$sp=1$g=1;} elseif ($act==ShutOuts) { $sort=1;  $display=$act$g=1;} else { $sort=""; }

    Which gives this:
    http://www.fifeflyers.co.uk/snlplayers.php?act=ShutOuts&g=1

    Which seems to work
  12. steven21 Ice Hockey Know All

    Seems ok actually now
  13. Andrew Taylor CS New Media Staff

    It looks like that line has been fixed, probably Nick having a look at the same time

    Glad it is working
  14. steven21 Ice Hockey Know All

  15. Andrew Taylor CS New Media Staff

    Yes, should be just a case of replacing that one line

    Edit: Seems to have been done already
  16. steven21 Ice Hockey Know All

    All done. Thanks Andrew!!!!!!
  17. Andrew Taylor CS New Media Staff

    Excellent, glad it is working

Share This Page