Jump to content

Fatal error: Call to a member function Execute() on a non-object


Hitster4

Recommended Posts

Hey all.

I am trying to make a mod for our fantasy football site but keep getting an error.

Fatal error: Call to a member function Execute() on a non-object in C:\Inetpub\wwwroot\phpffl\program_files\autorun\general\top_team.php on line 8.

Here is the code.

 

<?php
   global $PHP_SELF, $DB;
   $leagues_ID='1'; 
   $week='2';
   $week_ID=$week -1;
   $game_ID=$week_ID; 
   $sql="select ID, team_name from teams where leagues_ID='$leagues_ID';";
[b]   $teams_rs=$DB->Execute($sql);[/b]
while (!$teams_rs->EOF) {
   $top_team_ID=$teams_rs->fields('ID');
   $top_team_name=$teams_rs->fields('team_name');
   $top_team_points=get_total_points_game($top_team_ID, $week_ID, $week_ID, $leagues_ID);
//echo $top_team_points." ";
   $top_team_points_array[$top_team_name]=$top_team_points;
   $teams_rs->MoveNext();
   }
   $top_scoring_team_ID="";
   $top_scoring_team_name="";
   $top_scoring_points="";
   foreach(array_keys($top_team_points_array) as $key)
   {
   if ($top_team_points_array[$key] > $top_scoring_points)
   {
   $top_scoring_points=$top_team_points_array[$key];
   //$top_scoring_team_ID=$top_team_ID;
   $top_scoring_team_name=$key;
   }
   }
   $sql="insert into total_scores (team_ID, teams_name, week_id, total_score, leagues_ID) values('$top_team_ID', '$top_scoring_team_name', '$week_ID', '$top_scoring_points', '$leagues_ID');";
   $rs=$DB->Execute($sql);

echo "<br>";
echo "<br>";
echo "Weekly Top Scoring Team for Week $week_ID is: $top_scoring_team_name with a score of $top_scoring_points points!";
echo "<br>";
echo "<br>";
//print_r ($top_team_points_array);

echo "<br>";
echo "<br>";

$weekly_top_score=max($top_team_points_array);

?> 

 

I have a function in the global file looks like this.

 

/************** BEGIN ADDITIONAL FUNCTIONS **************************/

function get_top_scoring_teams()

{

 

  global $PHP_SELF, $DB, $PHPFFL_IMAGE_PATH;

  $sql="select * from total_scores order by week_ID DESC limit 1;";

  $teams_rs=$DB->Execute($sql);

while (!$teams_rs->EOF) {

  $team_ID=$teams_rs->fields('team_ID');

  $team_name=$teams_rs->fields('teams_name');

  $team_points=$teams_rs->fields('total_score');

  $week_ID=$teams_rs->fields('week_ID');

echo "The Top Scoring Team for <strong>Week $week_ID</strong> was <br><img src='{$PHPFFL_IMAGE_PATH}team_logos_standings/$team_ID.gif'><br> <strong>$team_name</strong> with a score of <strong>$team_points</strong> points. <hr>";

  $teams_rs->MoveNext();

  }

 

}

/************** BEGIN ADDITIONAL FUNCTIONS**************************/

 

Any one see what the issue might be?

I am running this on a windows 2003 server with iis 6 php 5.3 and mysql 5.1.5

 

Any help would be appreciated.

 

Thanks

Hitster4

Link to comment
Share on other sites

$DB is the database where the data resides. This function works in the next part of the file. 

 

function get_players_position_totals_team($teams_ID)
{
    global $DB;

    $players_position_totals_team=array();
    $teams_players_position_array=array();
    $sql="select players.ID, players.positionID from rosters, players where rosters.players_ID=players.ID and current_teams_ID=$teams_ID";
    $teams_rs=$DB->Execute($sql);
    while(!($teams_rs->EOF))
    {
        $current_players_ID=$teams_rs->fields("ID");
        $current_positionID=$teams_rs->fields("positionID");
        $teams_players_position_array[$current_players_ID]=$current_positionID;
        $teams_rs->MoveNext(); 

 

So I am pretty sure $DB is what I want.

But just not why it works in one spot but not in the other.

 

Thanks for the reply

 

Hitster4

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.