Topic: newscore.php problem

Alright well I've install the Arcade Mod with all the game packs but there seems to be a problem with the newscore and I have no clue what it is. Each time I submit the score the page turns blank.

<?php define('PUN_ROOT', './');
require PUN_ROOT.'include/common.php'; if ($pun_user['g_id'] == PUN_GUEST)
    error($lang_common['No permission']); // Recover the game name and the score 
$game_name = $HTTP_POST_VARS['game_name'];
// str_replace strips all spaces present in the score string
$score = str_replace(" ", "", $HTTP_POST_VARS['score']);
$topscore = 0;
$now = time();

// This is a fix for var "score" wich is send as "Score" and not as "score" like in game "Easter Egg Catch"    
if(empty($score))
    {
        $score = $HTTP_POST_VARS['Score'];
    }

if(!empty($game_name) && !empty($score))
{
    // Find Topscore
    $sql = 'SELECT rank_topscore, rank_score FROM '.$db->prefix.'arcade_ranking, '.$db->prefix.'users WHERE rank_player = '.$db->prefix.'users.id AND rank_game = "'.$game_name.'" ORDER BY rank_score DESC LIMIT 1';    
    $query = $db->query($sql) or error("Impossible to select topscore.", __FILE__, __LINE__, $db->error());
    $line = $db->fetch_assoc($query);
    if($line['rank_topscore'] = 1 && $line['rank_score'] < $score)
    {
        $sql = 'UPDATE '.$db->prefix.'arcade_ranking SET rank_topscore = '.$topscore.' WHERE rank_game = "'.$game_name.'"';
        $query = $db->query($sql) or error("Impossible to update the topscore", __FILE__, __LINE__, $db->error());
        $topscore = 1;
    }
    elseif($line['rank_topscore'] >= 0 && $line['rank_score'] <= $score)
    {
        $topscore = 1;        
    }
    else
    {
        $topscore = 0;
    }

    $sql = 'SELECT * FROM '.$db->prefix.'arcade_ranking WHERE rank_player = '.$pun_user['id'].' AND rank_game = "'.$game_name.'"';
    $query = $db->query($sql) or error("Impossible to select the user and game", __FILE__, __LINE__, $db->error());
    if(mysql_num_rows($query) > 0)
    {
        $line = $db->fetch_assoc($query);
        if($line['rank_score'] <= $score)
        {        
            // Update new highscore
            $sql = 'UPDATE '.$db->prefix.'arcade_ranking SET rank_score = '.$score.', rank_date = '.$now.' , rank_topscore = '.$topscore.' WHERE rank_player = '.$pun_user['id'].' AND rank_game = "'.$game_name.'"';
            $query = $db->query($sql) or error("Impossible to update new highscore", __FILE__, __LINE__, $db->error());
    
            $sql = 'SELECT game_id FROM '.$db->prefix.'arcade_games WHERE game_filename = "'.$game_name.'"';
            $query = $db->query($sql) or error("Impossible to select the game", __FILE__, __LINE__, $db->error());
            $gameid = $db->fetch_assoc($query);
            echo '<script type="text/javascript">window.location= "arcade_ranking.php?id='.$gameid['game_id'].'"</script>';
        }
        else
        {
            // No new highscore
            $sql = 'SELECT game_id FROM '.$db->prefix.'arcade_games WHERE game_filename = "'.$game_name.'"';
            $query = $db->query($sql) or error("Impossible to select the game", __FILE__, __LINE__, $db->error());
            $gameid = $db->fetch_assoc($query);
            echo '<script type="text/javascript">window.location= "arcade_play.php?id='.$gameid['game_id'].'"</script>';
        }
    }
    else
    {
        // Is there a score?
        $sql = 'SELECT rank_score, rank_topscore FROM '.$db->prefix.'arcade_ranking WHERE rank_game = "'.$game_name.'" ORDER BY rank_score DESC, rank_topscore DESC';
        $query = $db->query($sql) or error("Impossible to select the topscore", __FILE__, __LINE__, $db->error());
        $line = $db->fetch_assoc($query);
        if($line['rank_score'] <= 0 && $line['rank_topscore'] <= 0)
        {
            $topscore = 1;
        }

        // Add new Highscore
        $sql = 'INSERT INTO '.$db->prefix.'arcade_ranking (rank_game, rank_player, rank_score, rank_topscore, rank_date) VALUES    ("'.$game_name.'", '.$pun_user['id'].', '.$score.', '.$topscore.', '.$now.')';
        $query = $db->query($sql) or error("Impossible to insert the new score", __FILE__, __LINE__, $db->error());
        
        $sql = 'SELECT game_id FROM '.$db->prefix.'arcade_games WHERE game_filename = "'.$game_name.'"';
        $query = $db->query($sql) or error("Impossible to select the game", __FILE__, __LINE__, $db->error());
        $gameid = $db->fetch_assoc($query);
        echo '<script type="text/javascript">window.location= "arcade_ranking.php?id='.$gameid['game_id'].'"</script>';
    }
} else

{
    error($lang_common['No permission']);
} ?>

Could anyone help me out with this problem? Please and thank you.

[img]http://img90.imageshack.us/img90/746/scripter8ko.png[/img]
http://openwings.co.cc

2

Re: newscore.php problem

What error is printed in the server logs?

Re: newscore.php problem

resolved:  http://fluxbb.org/forums/post/3596/#p3596

4

Re: newscore.php problem

Lurker.boi wrote:

resolved:  http://fluxbb.org/forums/post/3596/#p3596

And the cross pollination starts smile