unfortunately after making some good progress after my other error i seem to have hit another wall with this error :-
Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /homepages/2/d398538194/htdocs/headtohead/instellingen.inc on line 704
ive looked at the code over and over again - ive searched google and various other posts with ppls issues but cant quite see where its going wrong.
Everything pointing to a tbl in the database is correct.
The connection is initiated at the top of the document in question also
im not sure how much code to add but just after the issue there is an ending ?> so ill paste up till i hit the opening tag
<?php
}
function get_value_average($player_id){
$sql = "SELECT u.player_value, t.team_stars ".
"FROM 5v5_users AS u, 5v5_team AS t ".
"WHERE u.user_id=$player_id ".
"AND t.team_id=u.team_id ";
$result = mysql_query($sql);
$row = mysql_fetch_array($result);
//opgehaald speler value en team_stars [0] en [1]
$sql_rates = "SELECT rate FROM 5v5_player_rates WHERE player_id=$player_id ORDER BY match_id";
$result_rates = mysql_query($sql_rates);
//echo "<br>$sql_rates";
$total_rate = 0;
$total_matches = 0;
$player_value = $row[0];
$team_stars = $row[1];
while($row_rates = mysql_fetch_array($result_rates)){
$total_matches++;
$total_rate = $total_rate + $row_rates[0];
$player_value = calculate_player_value($player_value, $team_stars, $row_rates[0]);
}
//echo "<br>aantalw: $total_matches, rate: $total_rate, player_value: $player_value";
if ($total_matches>0){
$av_rate = round(($total_rate / $total_matches),2);
}else{
$av_rate = "-";
}
//echo "<br>aantalw: $total_matches, rate: $total_rate, player_value: $player_value, av_rate: $av_rate";
$player_information[rate] = $av_rate;
$player_information[value] = $player_value;
$player_information[matches] = $total_matches;
//print_r($player_information);
return $player_information;
}
function calculate_player_value($player_value, $team_stars, $your_rating){
global $team_stars_max; //5
global $team_average; //7.5
/*
(your player value / $team_average) * your match rating
*/
//echo "<br>player_val = $player_value";
//echo "<br>team_av = $team_average";
//echo "<br>rating = $your_rating";
$sum1 = round(round(($player_value/$team_average)) * $your_rating);
//echo "<br>tot: $sum1";
/*
(sum1/100)*((team_stars_max-$team_stars)*10)
*/
$sum2 = ($sum1/100)*(($team_stars_max - $team_stars)*10);
$total_value = $sum1 + $sum2;
//echo "<br>total: $total_value";
return $total_value;
}
function get_match_info($game_id){
$sql = "SELECT league_id, hometeam_id, awayteam_id, home_result, away_result FROM fixtures_result WHERE game_id=$game_id";
//echo "<br>$sql";
$result = mysql_query($sql);
$row = mysql_fetch_array($result);
return $row;
}
function get_match_rating($match_id, $player_id){
$sql = "SELECT rate FROM 5v5_player_rates WHERE match_id=$match_id AND player_id=$player_id";
//echo "<br>$sql";
$result = mysql_query($sql);
$row = mysql_fetch_array($result);
return $row[0];
}
function insert_5v5_stats($game_id, $player_id, $level){
$sql = "INSERT INTO 5v5_player_rates (player_id, match_id, rate) ".
"VALUES ($player_id, $game_id, '$level')";
//echo "<br>$sql";
mysql_query($sql) or die("An error occured, please try again");
}
function random_league(){
$sql = "SELECT league_name FROM league WHERE league_type!='cup' AND subscription='yes' ORDER BY RAND() limit 1";
$result = mysql_query($sql);
$row = mysql_fetch_array($result);
return $row[0];
}
function random_team($league_id){
$sql = "SELECT t.team_name FROM team as t, competition as c where league_id='" . mysql_real_escape_string($league_id) . "' and c.team_id=t.team_id ORDER BY RAND() limit 1";
$result = mysql_query($sql);
$row = mysql_fetch_array($result);
return $row[0];
}
function get_league_weeknr($league_id){
$sql = "SELECT league_weeknr FROM league WHERE league_id='" . mysql_real_escape_string($league_id) . "'";
$result = mysql_query($sql);
$row = mysql_fetch_array($result);
return $row[0];
}
function show_not_played_fixtures($league="", $wide="small"){
if ($league=="")$league_id = get_league_id($league);
$weeknr = get_league_weeknr($league);
$sql = "SELECT league_id, hometeam_id, awayteam_id, game_id, week_nr ".
"FROM fixtures_result ".
"WHERE home_result IS NULL ";
if ($league!="all"){
$sql .= "AND league_id='" . mysql_real_escape_string($league) . "' AND week_nr < $weeknr ";
}
$sql .= "AND fixture_ignore='no' ";
$sql .= "ORDER BY week_nr";
//echo $sql;
$result = mysql_query($sql);
$colourclass = "fixturesLightRow";
while ($row = mysql_fetch_row($result)) {
$hometeam = get_team_information($row[1]);
$awayteam = get_team_information($row[2]);
$league = urlencode(get_league_name($row[0]));
$hometeamname = urlencode($hometeam[1]);
$awayteamname = urlencode($awayteam[1]);
$user_id = get_current_user_id($hometeam[0], $league_id);
$user_name_home = get_user_name($user_id);
$user_id = get_current_user_id($awayteam[0], $league_id);
$user_name_away = get_user_name($user_id);
if ($user_name_home != 'No User' AND $user_name_away != 'No User') {
?>
The line its on about is as follows and can be found "28" lines up from the bottom of the above php
while ($row = mysql_fetch_row($result)) {
any suggestions or help would be great - sites looking good now and im hoping itll be done soon
cheers in advance all