Parse error: parse error, unexpected $end in

Ich würd dir raten dir mal einen Editor mit Syntax Highlighting zuzulegen, dann kommst du selber und schneller auf solche Fehler.
 
Ich weiss, das Problem ist schon ziemlich alt, aber ich hatte gerade den selben Fehler in einem PHP-Skript (Parse error: parse error, unexpected $end in ...) und bin über Google auf diesen Thread aufmerksam geworden :)

Bei mir lag der Fehler daran, dass in der PHP-Konfiguration des Servers der verkürzte öffnende <? -Tag nicht zugelassen ist, sondern nur der normale <?php-Tag akzeptiert wird. Wenn ein Skript nun die verkürzten <?-Tags enthält, führt dies unweigerlich zu diesem Parse-Error. Also falls jemand zukünftig das gleiche Problem haben sollte, setzt mal den Hebel an dieser Stelle an :)
 
Hallo!

.....und bin über Google auf diesen Thread aufmerksam geworden.....
Ja ja, immer diese doofen Suchmaschinen. ;)
Also falls jemand zukünftig das gleiche Problem haben sollte, setzt mal den Hebel an dieser Stelle an :)
Um den Hebel mal etwas abzusägen :D, das Zauberwort heisst short_open_tag.
Dort steht auch warum man short_open_tag u.U. deaktiviert haben sollte.

Gruss Dr Dau
 
Habe das selbe Problem und als totaler php Neuling steig ich absolut noch nicht dahinter, ich hoffe ihr könnt mir helfen:

PHP:
<?php

include 'dbconnect.php';

   $ergebnis = mysql_query("SELECT * FROM Zitate");
while($daten = mysql_fetch_assoc($ergebnis)) {
    echo "<p>Autor: ".$daten["Autor"];
    echo "<br />Zitat: ".$daten["Zitat"];
    echo "</p>"; 
?>

Parse error: syntax error, unexpected $end in /mnt/cr1/08/369/00000016/htdocs/Homepage/zitate/index.php on line 20

Zeile 20 ist die letzte Zeile im Dokument.
 
Zuletzt bearbeitet von einem Moderator:
PHP Code bitte immer in[php ][/ php] - Tags!

PHP:
<?php

include 'dbconnect.php';

   $ergebnis = mysql_query("SELECT * FROM Zitate");
while($daten = mysql_fetch_assoc($ergebnis)) {
    echo "<p>Autor: ".$daten["Autor"];
    echo "<br />Zitat: ".$daten["Zitat"];
    echo "</p>";
} // schliessende Klammer vergessen! 
?>
 
Sers,hab auch so einen Fehler:

Parse error: syntax error, unexpected $end in /users/rayvez/www/emaster/eingabe.php on line 60

HTML:
if (mysql_num_rows($result)) {
      echo "<fieldset>
<legend>Suche ergab:</legend>Die englische Übersetzung für ".$ger." ist ".$row['Englisch'];
   } else{
      echo "<fieldset>
<legend>Suche ergab:</legend>Keinen Eintrag gefunden!<br />Tragen Sie es selbst ein!

<a href='einfügen.php'>Hier...</a></fieldset>";
    } 
if (empty($ger)) {echo "<fieldset><legend>Problem:</legend>
Sie haben keinen Suchbegriff eingegeben!</fieldset>" ;}

?>


</body>
</html>

Zeile 60 is ganz unten
HTML:
</html>
 
PHP:
if (mysql_num_rows($result)){
    echo "<fieldset>
          <legend>Suche ergab:</legend>
		  Die englische Übersetzung für ".$ger." ist ".$row['Englisch'];
}else{
   echo "<fieldset>
         <legend>Suche ergab:</legend>
		 Keinen Eintrag gefunden!<br />Tragen Sie es selbst ein!
         <a href='einfügen.php'>Hier...</a></fieldset>";
}
if(empty($ger)){
   echo "<fieldset><legend>Problem:</legend>
         Sie haben keinen Suchbegriff eingegeben!</fieldset>" ;
}
?>


</body>
</html>

Einfach mal den Code richtig einrücken und siehe da der Fehler liegt in den Codeteil den du nicht gepostest hast.

Gruss
 
Hab versucht nen Tippspiel für die neue Europaleague zu erstellen...beim aufrufen kommt folgender fehler:

Parse error: syntax error, unexpected $end in /usr/export/www/vhosts/funnetwork/hosting/wfe/phpBB2/includes/functions_el.php on line 860

Hier die funktions_el.php (zeile 860 ist die letzte Zeile!)...ich komm einfach nicht weiter und find den fehler nicht...
PHP:
<?php
/***************************************************************************
 *                              functions_el.php
 *                            -------------------
 *   for MOD              : Euro League
 *   version              : 1.0
 *   begin                : Sunday, Aug 23, 2009
 *   copyright            : (C) 2009 killer
 *   email                : see HP
 *   Bearbeitung	  : wrestlingfire.cwsurf.de
 *   based on             : WM WebTipp (C) AceVentura
 *
 ***************************************************************************/

/***************************************************************************
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 ***************************************************************************/
 
 if ( !defined('IN_PHPBB') )
{
   die("Hacking attempt");
} 

 // Get all config data
 function get_el_config() {

        global $db;

      //
	// Get config data
	//
	$sql = "SELECT * FROM " . EL_CONFIG_TABLE;
        if(!$result = $db->sql_query($sql))
        {
	        message_die(GENERAL_ERROR, "Could not query config information in el configuration", "", __LINE__, __FILE__, $sql);
        }
        else
        {
	    while( $row = $db->sql_fetchrow($result) )
	    {
		$config_name = $row['config_name'];
		$config_value = $row['config_value'];

		$new[$config_name] = $config_value;

	    }
        }
	$db->sql_freeresult($result);

	return $new;
 }

 // Get el teams data
 function get_el_teams($team_id = 0) {

        global $db;

      //
	// Get teams data
	//
	if( $team_id == 0 )
	{
        $sql = "SELECT *
		FROM  " . EL_TEAMS_TABLE . "
                ORDER BY team_id ASC";
        }
        else {
        $sql = "SELECT *
		FROM  " . EL_TEAMS_TABLE . "
                WHERE team_id = $team_id";
        }

	if( !($result = $db->sql_query($sql)) )
	{
		message_die(GENERAL_ERROR, 'Could not get teams data', '', __LINE__, __FILE__, $sql);
	}

	$el_teams = array();
	while ( $row = $db->sql_fetchrow($result) )
	{

		$el_teams[$row['team_id']] = $row;
	}
	$db->sql_freeresult($result);

	return $el_teams;

 }
 
 // Get el users data
 function get_el_users() {

        global $db;

      //
	// Get users data
	//
        $sql = "SELECT t.*, sum(tipp_points) AS user_points, count(tipp_points) as user_total_tipps
      FROM  " . EL_TIPPS_TABLE . " t, " . USERS_TABLE . " u
      WHERE tipp_user = user_id
      GROUP BY tipp_user
                ORDER BY user_points DESC, username";

	if( !($result = $db->sql_query($sql)) )
	{
		message_die(GENERAL_ERROR, 'Could not get user tipps data', '', __LINE__, __FILE__, $sql);
	}

	$el_users = array();
	while ( $row = $db->sql_fetchrow($result) )
	{
	//	$el_users[][$row['tipp_user']] = $row;
	   $el_users[] = $row;
	}
	$db->sql_freeresult($result);

	return $el_users;

 }
 
 // Get all users data
 function get_all_the_users() {

        global $db;

      //
	// Get users data
	//
        $sql = "SELECT user_id, username
		FROM  " . USERS_TABLE;

	if( !($result = $db->sql_query($sql)) )
	{
		message_die(GENERAL_ERROR, 'Could not get users data', '', __LINE__, __FILE__, $sql);
	}

	$users = array();
	while ( $row = $db->sql_fetchrow($result) )
	{
		$users[$row['user_id']] = $row['username'];
	}
	$db->sql_freeresult($result);

	return $users;

 }
 
 // Get el teams data order by groups
 function get_el_teamids_by_groups() {

        global $db;

      //
	// Get teams data
	//
        $sql = "SELECT *
		FROM  " . EL_TEAMS_TABLE . "
                ORDER BY team_id ASC";

	if( !($result = $db->sql_query($sql)) )
	{
		message_die(GENERAL_ERROR, 'Could not get teams data', '', __LINE__, __FILE__, $sql);
	}

	$el_teams = array();
	while ( $row = $db->sql_fetchrow($result) )
	{

		$el_teams[$row['team_group']][] = $row['team_id'];
	}
	$db->sql_freeresult($result);

	return $el_teams;

 }
 
 // Get el tipps data
 function get_el_tipps($calculate = 0, $user_id = 0) {

        global $db;

      //
	// Get tipps data
	//
	if ( $user_id == 0 ) {
	$sql = "SELECT *
		FROM  " . EL_TIPPS_TABLE . "
                ORDER BY tipp_id ASC";
        }
        else {
        $sql = "SELECT *
		FROM  " . EL_TIPPS_TABLE . "
		WHERE tipp_user = $user_id 

                ORDER BY tipp_id ASC";

        }
	if( !($result = $db->sql_query($sql)) )
	{
		message_die(GENERAL_ERROR, 'Could not get tipps data', '', __LINE__, __FILE__, $sql);
	}

	$el_tipps = array();
	while ( $row = $db->sql_fetchrow($result) )
	{
		if ( $calculate == 0 ) {
		   $el_tipps[$row['tipp_user']][$row['tipp_game']] = $row;
		}
		else {
                   $el_tipps[$row['tipp_game']][] = $row;
                }
	}
	$db->sql_freeresult($result);

	return $el_tipps;
 }

 // Get el games data
 function get_el_games($team_home = 0, $team_away = 0, $by_row = 0) {

        global $db;

        // Get all teams
        $teamsdata = get_el_teams();

      //
	// Get games data
	//
	if ( $team_home == 0 ) {
	$sql = "SELECT *
		FROM  " . EL_GAMES_TABLE . "
		    WHERE game_id < 97
                ORDER BY game_id ASC";
        }
        else {
        $sql = "SELECT *
		FROM  " . EL_GAMES_TABLE . "
                WHERE (game_home = $team_home AND game_away = $team_away) OR (game_home = $team_away AND game_away = $team_home)";
        }
	if( !($result = $db->sql_query($sql)) )
	{
		message_die(GENERAL_ERROR, 'Could not get games data', '', __LINE__, __FILE__, $sql);
	}

	$gamesdata = array();
	while ( $row = $db->sql_fetchrow($result) )
	{
		if ( $team_home == 0 && $by_row == 0)
		{
			if ($row['game_id'] < 13) {$group = 'A';}
			else if ($row['game_id'] < 25) {$group = 'B';}
			else if ($row['game_id'] < 37) {$group = 'C';}
			else if ($row['game_id'] < 49) {$group = 'D';}
			else if ($row['game_id'] < 61) {$group = 'E';}
			else if ($row['game_id'] < 73) {$group = 'F';}
			else if ($row['game_id'] < 85) {$group = 'G';}
			else if ($row['game_id'] < 97) {$group = 'H';}
			else if ($row['game_id'] < 109) {$group = 'I';}
			else if ($row['game_id'] < 121) {$group = 'J';}
			else if ($row['game_id'] < 133) {$group = 'K';}
			else if ($row['game_id'] < 145) {$group = 'L';}
			$row['game_group'] = $group;
			$gamesdata[$row['game_group']][] = $row;
		}
		else
		{
			$gamesdata[] = $row;
		}

	}
	$db->sql_freeresult($result);
	
	ksort($gamesdata);

	return $gamesdata;

 }

 // Get el finals data
 function get_el_finalgames() {

        global $db, $lang;

        // Get all teams
        $resultsdata = get_el_results();

      //
	// Get games data
	//
	$sql = "SELECT *
		FROM  " . EL_GAMES_TABLE . "
		    WHERE game_id > 96
                ORDER BY game_id ASC";

	if( !($result = $db->sql_query($sql)) )
	{
		message_die(GENERAL_ERROR, 'Could not get finals data', '', __LINE__, __FILE__, $sql);
	}

	$gamesdata = array();
	while ( $row = $db->sql_fetchrow($result) )
	{
		if ( $row['game_id'] < 161 ) {
                     $pseudo_group = $lang['l_el_sechzentelfinale'];
					 
					 if ( $row['game_id'] < 193 ) {
                     $pseudo_group = $lang['l_el_achtelfinale'];
		}
		else if ( $row['game_id'] < 201 ) {
                     $pseudo_group = $lang['l_el_viertelfinale'];
		}
		else if ( $row['game_id'] < 205 ) {
                     $pseudo_group = $lang['l_el_halbfinale'];
		}
		else {
                     $pseudo_group = $lang['l_el_finale'];
		}
                $row['game_group'] = $pseudo_group;
		$gamesdata[$pseudo_group][] = $row;
	}
	$db->sql_freeresult($result);

	return $gamesdata;

 }

 // Get el results data
 function get_el_results($game_id = 0, $by_row = 0) {

        global $db;

      //
	// Get results data
	//
	if ( $game_id == 0 ) {
	$sql = "SELECT *
		FROM  " . EL_RESULTS_TABLE . "
                ORDER BY result_game ASC";
        }
        else {
        $sql = "SELECT *
		FROM  " . EL_RESULTS_TABLE . "
                WHERE result_game = $game_id";
        }

        if( !($result = $db->sql_query($sql)) )
	{
		message_die(GENERAL_ERROR, 'Could not get results data', '', __LINE__, __FILE__, $sql);
	}

	$resultsdata = array();
	while ( $row = $db->sql_fetchrow($result) )
	{
		if ( $game_id == 0 && $by_row == 0) {
		        $resultsdata[$row['result_game']] = $row;
		}
		else {
		$resultsdata[] = $row;
                }
	}
	$db->sql_freeresult($result);

	return $resultsdata;

 }
 
 // Get teams order by teamname as row
 function get_el_teams_as_row() {

        global $db;

      //
	// Get teams data
	//
	$sql = "SELECT *
		FROM  " . EL_TEAMS_TABLE . "
                ORDER BY team_name";

        if( !($result = $db->sql_query($sql)) )
	{
		message_die(GENERAL_ERROR, 'Could not get teams data', '', __LINE__, __FILE__, $sql);
	}

	$resultsdata = array();
	while ( $row = $db->sql_fetchrow($result) )
	{
		$resultsdata[] = $row;
	}
	$db->sql_freeresult($result);

	return $resultsdata;

 }


 // Saves a users EL tipp
 function save_el_tipp($user_id, $tipped_winner) {

        global $db, $lang;
        
        $first_game      = get_first_game();
        $first_game_time = $first_game[0]['game_time'];
        $current_time = time();

        if ( $current_time < $first_game_time ) {
         //
	   // Delete old el tipp
	   //
	   $sql = "DELETE FROM " . EL_TIPPS_TABLE . " WHERE tipp_user = $user_id AND tipp_game = 126";
           if( !($result = $db->sql_query($sql)) )
	   {
		message_die(GENERAL_ERROR, 'Could not delete el tip', '', __LINE__, __FILE__, $sql);
	   }
	   //
	   // Insert el tipp
	   //
	   if ( $tipped_winner != 0 ) {
	   $sql = "INSERT INTO " . EL_TIPPS_TABLE . " (tipp_user,tipp_game,tipp_home) VALUES ($user_id,126,$tipped_winner)";
           if( !($result = $db->sql_query($sql)) )
	   {
		message_die(GENERAL_ERROR, 'Could not insert el tip', '', __LINE__, __FILE__, $sql);
	   }
	   }
	}

 }

 // Get first games data
 function get_first_game() {

        global $db;

      //
	// Get games data
	//
	$sql = "SELECT *
		FROM  " . EL_GAMES_TABLE . "
                ORDER BY game_time ASC LIMIT 1";

        if( !($result = $db->sql_query($sql)) )
	{
		message_die(GENERAL_ERROR, 'Could not get games data', '', __LINE__, __FILE__, $sql);
	}

	$resultsdata = array();
	while ( $row = $db->sql_fetchrow($result) )
	{
		$resultsdata[] = $row;
	}
	$db->sql_freeresult($result);

	return $resultsdata;

 }
 
 // Clear results table
 function clear_result($game_id) {

        global $db;

      //
	// Clear results data
	//

	$sql = "DELETE FROM " . EL_RESULTS_TABLE . "
                WHERE result_game = " . $game_id;

	if( !($result = $db->sql_query($sql)) )
	{
		message_die(GENERAL_ERROR, 'Could not reset result data', '', __LINE__, __FILE__, $sql);
	}


 }
 
 // Clear tipps table for a user
 function clear_tipps($user_id, $finals = 0) {

        global $db;

        $current_time = time();

      //
	// Clear usertipps data
	//
        if ( $finals == 0 ) {
	   $sql = "DELETE FROM " . EL_TIPPS_TABLE . "
                   WHERE tipp_user = $user_id AND tipp_game < 145 AND tipp_time > $current_time";
        }
        else {
           $sql = "DELETE FROM " . EL_TIPPS_TABLE . "
                   WHERE tipp_user = $user_id AND tipp_game > 144 AND tipp_game <> 206 AND tipp_time > $current_time";
        }
	if( !($result = $db->sql_query($sql)) )
	{
		message_die(GENERAL_ERROR, 'Could not reset usertipps data', '', __LINE__, __FILE__, $sql);
	}
 }

 // Save el results data
 function save_result($game_id, $home_val, $away_val, $winner = 0, $loser = 0) {

        global $db;

      //
	// Update results data
	//
	if ( $winner == 0 ) {
	$sql = "INSERT INTO " . EL_RESULTS_TABLE . " (result_game,result_home,result_away)
		VALUES ($game_id,$home_val,$away_val)";
	}
        else {
        $sql = "INSERT INTO " . EL_RESULTS_TABLE . " (result_game,result_home,result_away,final_winner,final_loser)
		VALUES ($game_id,$home_val,$away_val,$winner,$loser)";
        }
	if( !($result = $db->sql_query($sql)) )
	{
		message_die(GENERAL_ERROR, 'Could not update results data', '', __LINE__, __FILE__, $sql);
	}


 }

 // Save teams points and goals
 function save_points($teampoints, $teamgoals, $teamgotgoals) {

        global $db;
        
        $teams_data = get_el_teams();

        for ( $h = 0; $h < count($teams_data); $h++ ) {
      //
	// Update teams data
	//
        if ( isset($teampoints[$teams_data[$h]['team_id']]) ) {
	   $sql = "UPDATE " . EL_TEAMS_TABLE . "
		SET team_points = " . $teampoints[$teams_data[$h]['team_id']] . ", team_goals = " . $teamgoals[$teams_data[$h]['team_id']] . ", team_gotgoals = " . $teamgotgoals[$teams_data[$h]['team_id']] . "
                WHERE team_id = " . $teams_data[$h]['team_id'];
	   if( !($result = $db->sql_query($sql)) )
	   {
		message_die(GENERAL_ERROR, 'Could not update teams data', '', __LINE__, __FILE__, $sql);
	   }
        }
	}

 }

 // Save user tipps data
 function save_tipp($game_id, $user_id, $home_val, $away_val, $tipp_time) {

        global $db;

      //
	// Update tipps data
	//
	$sql = "INSERT INTO " . EL_TIPPS_TABLE . " (tipp_game,tipp_time,tipp_user,tipp_home,tipp_away)
		VALUES ($game_id,$tipp_time,$user_id,$home_val,$away_val)";
	if( !($result = $db->sql_query($sql)) )
	{
		message_die(GENERAL_ERROR, 'Could not update tipps data', '', __LINE__, __FILE__, $sql);
	}
 }


 // Sorts a grouparray for the standings
 function sort_standings($teams, $teams_data, $results_data, $games_data) {
                                 	
        $sorted_teams = array();

        for ( $z = 0; $z < count($teams); $z++ ) {

             $sorted_teams = insert_team($sorted_teams, $teams[$z], $teams_data, $games_data, $results_data);

        }

        return $sorted_teams;
 }

 // Inserts a team (needed for sort_standings())
 function insert_team($standings_array, $team_id, $teams_data, $games_data, $results_data) {

        $new_standings_array = array();

        for ( $k = 0; $k < count($standings_array); $k++ ) {

             $team_id_old     = $standings_array[$k];
             $team_id_new     = $team_id;
             $team_data_old   = $teams_data[$team_id_old];
             $team_data_new   = $teams_data[$team_id_new];
             $team_points_old = $team_data_old['team_points'];
             $team_points_new = $team_data_new['team_points'];

             if ( $team_points_old < $team_points_new ) {
                  $team_id = $team_id_old;
                  $standings_array[$k] = $team_id_new;

             }
             else if ( $team_points_old == $team_points_new ) {
                  $new_standings_array = find_winner_on_deuce($team_id_new, $team_id_old, $games_data, $results_data, $teams_data);
                  $team_id = $new_standings_array[1];
                  $standings_array[$k] = $new_standings_array[0];
             }

        }
        $standings_array[] = $team_id;

        return $standings_array;
 }
 
 // Filters games array
 function get_el_spec_game($team_home, $team_away, $games_data) {
          for ( $t = 0; $t < 97; $t++ ) {
             if ( ($games_data[$t]['game_home'] == $team_home && $games_data[$t]['game_away'] == $team_away) || ($games_data[$t]['game_home'] == $team_away && $games_data[$t]['game_away'] == $team_home) ) {
                 return $games_data[$t];
             }
          }
          return array();
 }

 // Sorts a grouparray for the standings
 function find_winner_on_deuce($team_id_new, $team_id_old, $games_data, $results_data, $teams_data) {

        $game_data    = get_el_spec_game($team_id_new, $team_id_old, $games_data);
        $game_results = $results_data[$game_data['game_id']];


        $team_in_order = array();

        if ( $game_results['result_home'] > $game_results['result_away']  ) {

                $team_in_order[] = $game_data['game_home'];
                $team_in_order[] = $game_data['game_away'];

        }
        else if ( $game_results['result_home'] < $game_results['result_away']  ) {

                $team_in_order[] = $game_data['game_away'];
                $team_in_order[] = $game_data['game_home'];

        }
        else {

                $teamdata_home = $teams_data[$game_data['game_home']];
                $teamdata_away = $teams_data[$game_data['game_away']];

             if ( ($teamdata_home['team_goals']-$teamdata_home['team_gotgoals']) > ($teamdata_away['team_goals']-$teamdata_away['team_gotgoals'])  ) {

                $team_in_order[] = $game_data['game_home'];
                $team_in_order[] = $game_data['game_away'];

             }
             else if ( ($teamdata_home['team_goals']-$teamdata_home['team_gotgoals']) < ($teamdata_away['team_goals']-$teamdata_away['team_gotgoals'])  ) {

                $team_in_order[] = $game_data['game_away'];
                $team_in_order[] = $game_data['game_home'];

             }
             else {

             if ( $teamdata_home['team_goals'] > $teamdata_away['team_goals']  ) {

                $team_in_order[] = $game_data['game_home'];
                $team_in_order[] = $game_data['game_away'];

             }
             else if ( $teamdata_home['team_goals'] < $teamdata_away['team_goals']  ) {

                $team_in_order[] = $game_data['game_away'];
                $team_in_order[] = $game_data['game_home'];

             }
             else {
                // When this code is reached, the UEFA has to define winners by a random selection. I just use defaults in here.
                // Correct gorup winners in ACP.
                $team_in_order[] = $team_id_old;
                $team_in_order[] = $team_id_new;
             }
             }
        }

        return $team_in_order;
 }
 
 // Get el auth status
 function get_el_auth() {

  global $db, $el_config, $userdata;

      $access_group = $el_config['restrict_to'];
      $sql = "SELECT g.group_id FROM " . GROUPS_TABLE . " g, " . USER_GROUP_TABLE . " ug
      WHERE g.group_id = ug.group_id
      AND ug.user_id = " . $userdata['user_id'] . "
      AND ug.user_pending <> " . TRUE . "
      AND g.group_single_user <> " . TRUE . "
      AND g.group_id = $access_group";
      if ( !$result = $db->sql_query($sql) )
      {
         message_die(GENERAL_ERROR, 'Could not get el auth data', '', __LINE__, __FILE__, $sql);
      }
      $check_el_auth = $db->sql_numrows($result);
      $db->sql_freeresult($result);
      if ( $check_el_auth != 0 )
      {
   	return TRUE;
      }
      return FALSE;
}

// Calculate user points
 function calculate_user_points($user_id = 0) {

  global $db, $el_config;
  
  // Reset all tippoints
  if ( $user_id == 0 ) {
  $sql = "UPDATE " . EL_TIPPS_TABLE . " SET tipp_points = 0";
  } 
  else {
  $sql = "UPDATE " . EL_TIPPS_TABLE . " SET tipp_points = 0 WHERE tipp_user = $user_id";
  }
  if( !($result = $db->sql_query($sql)) )
  {
        message_die(GENERAL_ERROR, 'Could not update tipps data', '', __LINE__, __FILE__, $sql);
  }

  $el_results = get_el_results(0,1);
  $el_tipps   = get_el_tipps(1, $user_id);


  for ( $i = 0; $i < count($el_results); $i++ ) {
       $current_game_id = $el_results[$i]['result_game'];
       $result_home     = $el_results[$i]['result_home'];
       $result_away     = $el_results[$i]['result_away'];

       for ( $u = 0; $u < count($el_tipps[$current_game_id]); $u++ ) {

            $tipp_home   = $el_tipps[$current_game_id][$u]['tipp_home'];
            $tipp_away   = $el_tipps[$current_game_id][$u]['tipp_away'];
            $tipp_points = $el_tipps[$current_game_id][$u]['tipp_points'];
            $tipp_new_points = 0;
            

           if ( $current_game_id != 126 ) {
            if ( $tipp_home == $result_home && $tipp_away == $result_away ) {
                      $tipp_new_points = $el_config['points_match'];
            }
            else if ( $tipp_home - $tipp_away == $result_home - $result_away ) {
                      $tipp_new_points = $el_config['points_tordiff'];
            }
            else if ( ($tipp_home > $tipp_away && $result_home > $result_away) || ($tipp_home < $tipp_away && $result_home < $result_away) ) {
                      $tipp_new_points = $el_config['points_tendency'];
            }
           }
           else {
             if ( $tipp_home == $result_home ) {
                      $tipp_new_points = $el_config['points_winner'];
             }
           }


            if ( $tipp_new_points != $tipp_points ) {
                      $sql = "UPDATE " . EL_TIPPS_TABLE . "
                               SET tipp_points = $tipp_new_points
                               WHERE tipp_id = " . $el_tipps[$current_game_id][$u]['tipp_id'];
	              if( !($result = $db->sql_query($sql)) )
	              {
		          message_die(GENERAL_ERROR, 'Could not update tipps data', '', __LINE__, __FILE__, $sql);
	              }
            }


       }

  }

 }

 // get users el winner tipp
 function get_el_winner($user_id)
 {
   global $db;
   
   $sql = "SELECT * FROM " . EL_TIPPS_TABLE . " WHERE tipp_game = 206 AND tipp_user = " . $user_id;
	              if( !($result = $db->sql_query($sql)) )
	              {
		          message_die(GENERAL_ERROR, 'Could not get tipps data', '', __LINE__, __FILE__, $sql);
	              }
   $winnerdata = 0;
	while ( $row = $db->sql_fetchrow($result) )
	{
		$winnerdata = $row['tipp_home'];
	}
	$db->sql_freeresult($result);
	
	return $winnerdata;

 }
 
 function get_el_champion_tipps()
 {
   global $db;

   $sql = "SELECT * FROM " . EL_TIPPS_TABLE . " WHERE tipp_game = 126";
	              if( !($result = $db->sql_query($sql)) )
	              {
		          message_die(GENERAL_ERROR, 'Could not get tipps data', '', __LINE__, __FILE__, $sql);
	              }
   $championsdata = array();
	while ( $row = $db->sql_fetchrow($result) )
	{
		$championsdata[$row['tipp_user']] = $row['tipp_home'];
	}
	$db->sql_freeresult($result);
	
	return $championsdata;

 }

// Get el gametimes by id
 function get_el_gametimes() {

        global $db;

      //
	// Get games data
	//
	$sql = "SELECT game_id, game_time
		FROM  " . EL_GAMES_TABLE;

	if( !($result = $db->sql_query($sql)) )
	{
		message_die(GENERAL_ERROR, 'Could not get games data', '', __LINE__, __FILE__, $sql);
	}

	$gamesdata = array();
	while ( $row = $db->sql_fetchrow($result) )
	{
                $gamesdata[$row['game_id']] = $row['game_time'];
	}
	$db->sql_freeresult($result);


	while ( $row = $db->sql_fetchrow($result) )
	{
                $gamesdata[$row['game_id']] = $row['game_time'];
	}
	$db->sql_freeresult($result);


	return $gamesdata;

 }

?>
 
Zurück