*Looks at line 36*
PHP Code:
$random = array_rand($replace);
I would assume, $replace is not an array. the best fix I can give you is:
PHP Code:
if(is_array($replace)){ $random = array_rand($replace); // do rest of script. } else { // say an error occurred. }
So your script should look something like:
PHP Code:
function fixtures2($league_id) { mysql_query("TRUNCATE TABLE `manager__fixtures`");
$match_day = 0; while($match_day < 19) { $match_day++; echo "<strong>Match Day: $match_day</strong><br /><br />"; $clubs = mysql_query("SELECT * FROM `manager__teams` WHERE `league` = '$league_id' LIMIT 20"); while($row2 = mysql_fetch_array($clubs)) { // Generate List Of Teams In League $teams = mysql_query("SELECT * FROM `manager__teams` WHERE `league` = '$league_id' LIMIT 20"); while($row = mysql_fetch_row($teams)) { $myArray[$row[0]] = $row[1]; } // Delete Teams From List Who Are Already Playing $fixtures = mysql_query("SELECT * FROM `manager__fixtures` WHERE `league` = '$league_id' && `match_day` = '$match_day' LIMIT 20"); while($fixtures2 = mysql_fetch_array($fixtures)) { $home = mysql_fetch_array(mysql_query("SELECT * FROM `manager__teams` WHERE `id` = '" . $fixtures['home_team'] . "' LIMIT 1")); $away = mysql_fetch_array(mysql_query("SELECT * FROM `manager__teams` WHERE `id` = '" . $fixtures['away_team'] . "' LIMIT 1"));
$replace = str_replace($home['team'], "", $myArray); $replace = str_replace($away['team'], "", $replace); } // Delete Teams From List Who Have Already Played At This Team $fixtures1 = mysql_query("SELECT * FROM `manager__fixtures` WHERE `league` = '$league_id' && `match_day` = '$match_day' && `home_team` = '" . $row2['id'] . "' LIMIT 20"); while($fixtures2 = mysql_fetch_array($fixtures1)) { $replace = str_replace($fixtures2['away_team'], "", $replace); } // Pick Team To Play
if(is_array($replace)){ $random = array_rand($replace); $team = $replace[$random];
$id = mysql_fetch_array(mysql_query("SELECT * FROM `manager__teams` WHERE `team` = '$team' LIMIT 1"));
mysql_query("INSERT INTO `manager__fixtures` ( `id` , `home_team` , `away_team` , `date` , `type`, `league`, `match_day` ) VALUES ('', '" . $row2['id'] . "', '" . $id['id'] . "', '0', 'League', '$league_id', '$match_day')");
// Show Results echo "<strong>" . $row2['id'] . "</strong> <br />" . print_r($myArray) . "<br /><br />"; } else { echo "Sorry, nothing to show :("; } } } } echo fixtures2("2");
__________________
My Blog/Site: Please login or register to view this content. Registration is FREE
Last edited by rogem002; 02-17-2008 at 12:44 PM..
|