Doubled entries ..

форум посвящен дальнейшим разработкам базового мода SUDOKU

Moderator: el_teniente

Doubled entries ..

Postby femu on Mon Feb 18, 2008 12:34 pm

i,



a small issue. As you can see in the attached picture, there are doubled entries in the Samurai/Ninja highscores. Which table do I need to check, to get that corrected?



Thanks,

femu
Attachments
sudoku_highscores.jpg
femu
Мастер-ковбой
Мастер-ковбой
 
Posts: 84
Joined: Sat May 19, 2007 8:15 pm
Gender: Male
Country: Germany

Postby el_teniente on Mon Feb 18, 2008 1:13 pm

ou must check the table phpbb_sudoku_stats



this is very strange because the field user_id has primary key(check if so) and no duplication is allowed----it's a malfunction of your MySQL server



find and delete the second instance for each user_id duplication using phpMyAdmin or so
die hard---live easy
User avatar
el_teniente
Статс-админ
Статс-админ
 
Posts: 4283
Joined: Mon Nov 07, 2005 7:51 pm
Location: Белокаменная
Gender: Male
Country: Russian Federation

Postby femu on Mon Feb 18, 2008 1:51 pm

i,



that was confusing me too. I can't see duplicates ... and. The user_id isn't indexed ..



Attached the phpMyAdmin export of the stats table ... Maybe there are fields, which shouldn't be there anymore?



hanks,

Felix
Attachments
orion_sudoku_stats.zip
(1.15 KB) Downloaded 843 times
femu
Мастер-ковбой
Мастер-ковбой
 
Posts: 84
Joined: Sat May 19, 2007 8:15 pm
Gender: Male
Country: Germany

Postby el_teniente on Mon Feb 18, 2008 2:06 pm

our table has not primary key at the field user_id

winkk:::



try to run those queries:



Code: Select all
REPAIR TABLE orion_sudoku_stats;

ALTER TABLE orion_sudoku_stats DROP INDEX `user_id`;

ALTER TABLE orion_sudoku_stats ADD PRIMARY KEY ( `user_id` );

die hard---live easy
User avatar
el_teniente
Статс-админ
Статс-админ
 
Posts: 4283
Joined: Mon Nov 07, 2005 7:51 pm
Location: Белокаменная
Gender: Male
Country: Russian Federation

Postby femu on Mon Feb 18, 2008 2:29 pm

ope. Still the same result ...

femu
Мастер-ковбой
Мастер-ковбой
 
Posts: 84
Joined: Sat May 19, 2007 8:15 pm
Gender: Male
Country: Germany

Postby el_teniente on Mon Feb 18, 2008 2:35 pm

M me your file sudoku.php please



and what is your version of MySQL?
die hard---live easy
User avatar
el_teniente
Статс-админ
Статс-админ
 
Posts: 4283
Joined: Mon Nov 07, 2005 7:51 pm
Location: Белокаменная
Gender: Male
Country: Russian Federation

Postby femu on Mon Feb 18, 2008 3:05 pm

ou have PM.



Thanks for taking a look!
femu
Мастер-ковбой
Мастер-ковбой
 
Posts: 84
Joined: Sat May 19, 2007 8:15 pm
Gender: Male
Country: Germany

Postby el_teniente on Mon Feb 18, 2008 3:10 pm

ooops, you have old hidden bug found :shock:



OPEN sudoku.php



FIND
Code: Select all
// START LEADERBOARD MOD


and
Code: Select all
// END LEADERBOARD MOD




REPLACE EVERYTHING BETWEEN WITH:

Code: Select all
if ( $mode == 'leaderboard' )

{

// grab full leaderboard

$sql =" SELECT * FROM " . SUDOKU_STATS . "

WHERE played > 0

ORDER BY points DESC

";

if ( !($result = $db->sql_query($sql)) )

{

   message_die(GENERAL_ERROR, 'Error in retrieving Sudoku userdata', '', __LINE__, __FILE__, $sql);

}

$x=1;

while ( $row=$db->sql_fetchrow($result) )

{

   $stat_points=$row['points'];

   $stat_played=$row['played'];

   $stat_helper=(!$row['helper_hide'])?$row['game_helper']:'X';

   $stat_level=$lang['Sudoku_play_level_' . $row['play_level'] . ''];

   $stat_userid=$row['user_id'];

   $stat_hs1=$row['highscores1'];

   $stat_hs2=$row['highscores2'];

   $stat_hs3=$row['highscores3'];

   $stat_hssp=$row['highscores_special'];

   $stat_hspl=$row['highscores_played'];

   

    $stat_average=($stat_played)?round($stat_points/$stat_played):0;

   

   $sql_b=" SELECT username FROM " . USERS_TABLE . "

   WHERE user_id=" . $row['user_id'];

   if ( !($result_b = $db->sql_query($sql_b)) )

   {

      message_die(GENERAL_ERROR, 'Error in retrieving Sudoku userdata', '', __LINE__, __FILE__, $sql_b);

   }

   $row_b=$db->sql_fetchrow($result_b);

   $stat_username=$row_b['username'];

   // grab current game

   $sql_b=" SELECT game_pack, game_num FROM " . SUDOKU_USERS . "

   WHERE user_id=" . $row['user_id'] . " and game_type='sudoku'

   ORDER BY game_pack DESC, game_num DESC

   LIMIT 1

   ";

   if ( !($result_b = $db->sql_query($sql_b)) )

   {

      message_die(GENERAL_ERROR, 'Error in retrieving Sudoku userdata', '', __LINE__, __FILE__, $sql_b);

   }

   $row_b=$db->sql_fetchrow($result_b);

   $stat_gamepack=$row_b['game_pack'];

   $stat_gamenum=$row_b['game_num'];

   

   // send to template

$row_color = ( !($x % 2) ) ? $theme['td_color1'] : $theme['td_color2'];

$row_class = ( !($x % 2) ) ? $theme['td_class1'] : $theme['td_class2'];

   

   $template->set_filenames(array(

   'body' => 'sudokuleaders.tpl')

   );

   

   $template->assign_block_vars('leaderboard', array(

   'ROW_COLOR' => '#' . $row_color,

   'ROW_CLASS' => $row_class,

   'USERNAME' => '<a>' . $stat_username . '</a>',

   'POINTS' => $stat_points,

   'HIGHSCORES1' => $stat_hs1,

   'HIGHSCORES2' => $stat_hs2,

   'HIGHSCORES3' => $stat_hs3,

   'HIGHSCORES_SPECIAL' => $stat_hssp,

   'HIGHSCORES_PLAYED' => $stat_hspl,

   'PLAYED' => $stat_played,

   'HELPER' => $stat_helper,

   'LEVEL' => $stat_level,

    'AVERAGE_POINTS' => $stat_average,

   'POS' => $x,

   'CURRENT_GAME' => sprintf($lang['sudoku_current_game_text'], $stat_gamepack, $lang['#'],$stat_gamenum),

   ));

   $x++;

}

if(!$row)

  {

  $template->set_filenames(array(

   'body' => 'sudokuleaders.tpl')

   );

  }

}

else if ( $mode == 'samurai_leaderboard' )

{



$sql = " SELECT * FROM " . SUDOKU_STATS . "

WHERE samurai_points > 0 || ninja_points > 0

ORDER BY samurai_points + ninja_points DESC";

if ( !($result = $db->sql_query($sql)) )

{

   message_die(GENERAL_ERROR, 'Error in retrieving Sudoku userdata', '', __LINE__, __FILE__, $sql);

}

$x=1;

while ( $row=$db->sql_fetchrow($result) )

{

   $stat_points=$row['samurai_points'];

   $stat_played=$row['samurai_played'];

   $stat_points_ninja=$row['ninja_points'];

   $stat_played_ninja=$row['ninja_played'];

   $stat_userid=$row['user_id'];



$stat_average=($stat_played)?round($stat_points/$stat_played):0;

$stat_average_ninja=($stat_played_ninja)?round($stat_points_ninja/$stat_played_ninja):0;



   $sql_a=" SELECT username FROM " . USERS_TABLE . "

   WHERE user_id=" . $row['user_id'];

   if ( !($result_a = $db->sql_query($sql_a)) )

   {

      message_die(GENERAL_ERROR, 'Error in retrieving Sudoku userdata', '', __LINE__, __FILE__, $sql_a);

   }

   $row_a=$db->sql_fetchrow($result_a);

   $stat_username=$row_a['username'];

   // grab current game

   $sql_a = ' SELECT game_pack, game_num FROM ' . SUDOKU_USERS . "

   WHERE user_id = " . $row['user_id'] . "

   AND game_type='samurai'

   ORDER BY game_pack DESC, game_num DESC

   LIMIT 1

   ";

   if ( !($result_a = $db->sql_query($sql_a)) )

   {

      message_die(GENERAL_ERROR, 'Error in retrieving Sudoku userdata', '', __LINE__, __FILE__, $sql_a);

   }

   $row_a=$db->sql_fetchrow($result_a);

   $stat_gamepack=$row_a['game_pack'];

   $stat_gamenum=$row_a['game_num'];

   $sql_b=" SELECT game_pack, game_num FROM " . SUDOKU_USERS . "

   WHERE user_id=" . $row['user_id'] . "

   AND game_type = 'ninja'

   ORDER BY game_pack DESC, game_num DESC

   LIMIT 1

   ";

   if ( !($result_b = $db->sql_query($sql_b)) )

   {

      message_die(GENERAL_ERROR, 'Error in retrieving Sudoku userdata', '', __LINE__, __FILE__, $sql_b);

   }

   $row_b=$db->sql_fetchrow($result_b);

   $stat_gamepack_ninja=$row_b['game_pack'];

   $stat_gamenum_ninja=$row_b['game_num'];

   $ninja_stats =($row_b['game_pack']&&$row_b['game_num'])?'<br>' . sprintf($lang['sudoku_current_game_text'], $stat_gamepack_ninja,$lang['#'], $stat_gamenum_ninja) .'':'';

   $samurai_level=$lang['Sudoku_play_level_' . $row['samurai_play_level'] . ''];

   $ninja_level=$lang['Sudoku_play_level_' . $row['ninja_play_level'] . ''];

   // send to template

   $row_color = ( !($x % 2) ) ? $theme['td_color1'] : $theme['td_color2'];

   $row_class = ( !($x % 2) ) ? $theme['td_class1'] : $theme['td_class2'];

   $crown = '';

   if($x==1&&$stat_points+$stat_points_ninja>0)

   {

      $crown ='<img> ';

    }

    else if($x==2&&$stat_points+$stat_points_ninja>0)

    {

      $crown ='<img> ';

    }

    else if($x==3&&$stat_points+$stat_points_ninja>0)

    {

      $crown ='<img> ';

    }

   

    $template->set_filenames(array(

   'body' => 'sudoku_leaders.tpl')

   );

   $template->assign_block_vars('leaderboard', array(

   'ROW_COLOR' => '#' . $row_color,

   'ROW_CLASS' => $row_class,

   'USERNAME' => '' . $crown . '<a>' . $stat_username . '</a>',

   'SAMURAI_POINTS' => $stat_points,

   'NINJA_POINTS' => $stat_points_ninja,

   'SAMURAI_PLAYED' => $stat_played,

   'NINJA_PLAYED' => $stat_played_ninja,

    'SAMURAI_AVERAGE' => $stat_average,

    'NINJA_AVERAGE' => $stat_average_ninja,

    'SAMURAI_LEVEL' => $samurai_level,

    'NINJA_LEVEL' => $ninja_level,

    'BEST_SAMURAI' => $row['best_samurai'],

    'BEST_NINJA' => $row['best_ninja'],

   'POS' => $x,

   'CURRENT_GAME' => sprintf($lang['sudoku_current_game_text'], $stat_gamepack,$lang['#'], $stat_gamenum) . $ninja_stats,

   ));

   $x++;

  }

  if(!$row)

  {

  $template->set_filenames(array(

   'body' => 'sudoku_leaders.tpl')

   );

  }

}

else

{

// grab the top ten

$sql = ' SELECT * FROM ' . SUDOKU_STATS . "

ORDER BY points DESC LIMIT 10

";

if ( !($result = $db->sql_query($sql)) )

{

   message_die(GENERAL_ERROR, 'Error in retrieving Sudoku userdata', '', __LINE__, __FILE__, $sql);

}

$x=1;

while ( $row=$db->sql_fetchrow($result) )

{

   $stat_points=$row['points'];

   $stat_played=$row['played'];

   $stat_helper=(!$row['helper_hide'])?$row['game_helper']:'X';

   $stat_userid=$row['user_id'];

    $stat_average=($stat_played)?round($stat_points/$stat_played):0;

   

   $sql_a=" SELECT username FROM " . USERS_TABLE . "

   WHERE user_id=" . $row['user_id'];

   if ( !($result_a = $db->sql_query($sql_a)) )

   {

      message_die(GENERAL_ERROR, 'Error in retrieving Sudoku userdata', '', __LINE__, __FILE__, $sql_a);

   }

   $row_a=$db->sql_fetchrow($result_a);

   $stat_username=$row_a['username'];

   // grab current game

   $sql_a= ' SELECT game_pack, game_num FROM ' . SUDOKU_USERS . "

   WHERE user_id=" . $row['user_id'] . " AND game_type='sudoku'

   ORDER BY game_pack DESC, game_num DESC

   LIMIT 1

   ";

   if ( !($result_a = $db->sql_query($sql_a)) )

   {

      message_die(GENERAL_ERROR, 'Error in retrieving Sudoku userdata', '', __LINE__, __FILE__, $sql_a);

   }

   $row_a=$db->sql_fetchrow($result_a);

   $stat_gamepack=$row_a['game_pack'];

   $stat_gamenum=$row_a['game_num'];

   

   // send to template

   $row_color = ( !($x % 2) ) ? $theme['td_color1'] : $theme['td_color2'];

   $row_class = ( !($x % 2) ) ? $theme['td_class1'] : $theme['td_class2'];

   

   $template->assign_block_vars('leaderboard', array(

   'ROW_COLOR' => '#' . $row_color,

   'ROW_CLASS' => $row_class,

   'USERNAME' => '<a>' . $stat_username . '</a>',

   'POINTS' => $stat_points,

   'PLAYED' => $stat_played,

   'HELPER' => $stat_helper,

    'AVERAGE_POINTS' => $stat_average,

   'POS' => $x,

   'CURRENT_GAME' => sprintf($lang['sudoku_current_game_text'], $stat_gamepack,$lang['#'], $stat_gamenum),

   ));

   $x++;

}

}

// grab the top ten samurai/ninja

   $sql = ' SELECT * FROM ' . SUDOKU_STATS . "

   WHERE samurai_points > 0 || ninja_points > 0

   ORDER BY samurai_points + ninja_points DESC LIMIT 10";

if ( !($result = $db->sql_query($sql)) )

{

   message_die(GENERAL_ERROR, 'Error in retrieving Sudoku userdata', '', __LINE__, __FILE__, $sql);

}

$x=1;

while ( $row = $db->sql_fetchrow($result) )

{

   $stat_points=$row['samurai_points'];

   $stat_played=$row['samurai_played'];

   $stat_points_ninja=$row['ninja_points'];

   $stat_played_ninja=$row['ninja_played'];

   $stat_userid=$row['user_id'];



$stat_average=($stat_played)?round($stat_points/$stat_played):0;

$stat_average_ninja=($stat_played_ninja)?round($stat_points_ninja/$stat_played_ninja):0;



   $sql_a=" SELECT username FROM " . USERS_TABLE . "

   WHERE user_id=" . $row['user_id'];

   if ( !($result_a = $db->sql_query($sql_a)) )

   {

      message_die(GENERAL_ERROR, 'Error in retrieving Sudoku userdata', '', __LINE__, __FILE__, $sql_a);

   }

   $row_a=$db->sql_fetchrow($result_a);

   $stat_username=$row_a['username'];

   // grab current game

   $sql_a = ' SELECT game_pack, game_num FROM ' . SUDOKU_USERS . "

   WHERE user_id = " . $row['user_id'] . "

   AND game_type = 'samurai'

   ORDER BY game_pack DESC, game_num DESC

   LIMIT 1

   ";

   if ( !($result_a = $db->sql_query($sql_a)) )

   {

      message_die(GENERAL_ERROR, 'Error in retrieving Sudoku userdata', '', __LINE__, __FILE__, $sql_a);

   }

   $row_a=$db->sql_fetchrow($result_a);

   $stat_gamepack=$row_a['game_pack'];

   $stat_gamenum=$row_a['game_num'];

   $sql_b = ' SELECT game_pack, game_num FROM ' . SUDOKU_USERS . "

   WHERE user_id=" . $row['user_id'] . "

   AND game_type='ninja'

   ORDER BY game_pack DESC, game_num DESC

   LIMIT 1

   ";

   if ( !($result_b = $db->sql_query($sql_b)) )

   {

      message_die(GENERAL_ERROR, 'Error in retrieving Sudoku userdata', '', __LINE__, __FILE__, $sql_b);

   }

   $row_b=$db->sql_fetchrow($result_b);

   $stat_gamepack_ninja=$row_b['game_pack'];

   $stat_gamenum_ninja=$row_b['game_num'];

   $ninja_stats =($row_b['game_pack']&&$row_b['game_num'])?'<br>' . sprintf($lang['sudoku_current_game_text'], $stat_gamepack_ninja,$lang['#'], $stat_gamenum_ninja) .'':'';

   

   // send to template

   $row_color = ( !($x % 2) ) ? $theme['td_color1'] : $theme['td_color2'];

   $row_class = ( !($x % 2) ) ? $theme['td_class1'] : $theme['td_class2'];

   $crown = '';

   if($x==1&&$stat_points+$stat_points_ninja>0)

   {

      $crown ='<img> ';

    }

    else if($x==2&&$stat_points+$stat_points_ninja>0)

    {

      $crown ='<img> ';

    }

    else if($x==3&&$stat_points+$stat_points_ninja>0)

    {

      $crown ='<img> ';

    }

   

   

   $template->assign_block_vars('samurai_leaderboard', array(

   'ROW_COLOR' => '#' . $row_color,

   'ROW_CLASS' => $row_class,

   'USERNAME' => '' . $crown . '<a>' . $stat_username . '</a>',

   'POINTS' => $stat_points . '<br>' . $stat_points_ninja,

   'PLAYED' => $stat_played . '/' . $stat_played_ninja,

    'AVERAGE_POINTS' => $stat_average . '<br>' . $stat_average_ninja,

   'POS' => $x,

   'CURRENT_GAME' => sprintf($lang['sudoku_current_game_text'], $stat_gamepack,$lang['#'], $stat_gamenum) . $ninja_stats,

   ));

   $x++;

}




it's time to create a new version to update roll:::
die hard---live easy
User avatar
el_teniente
Статс-админ
Статс-админ
 
Posts: 4283
Joined: Mon Nov 07, 2005 7:51 pm
Location: Белокаменная
Gender: Male
Country: Russian Federation

Postby el_teniente on Mon Feb 18, 2008 3:13 pm

have MySQL 6 and it doesn't pay attention to this bug roll:::

die hard---live easy
User avatar
el_teniente
Статс-админ
Статс-админ
 
Posts: 4283
Joined: Mon Nov 07, 2005 7:51 pm
Location: Белокаменная
Gender: Male
Country: Russian Federation

Postby femu on Mon Feb 18, 2008 3:23 pm

:-D



That's me. Thanks for the fast fix! Now it shows it correctly!



Isn't PHP6 still in beta?



egards,

Felix
femu
Мастер-ковбой
Мастер-ковбой
 
Posts: 84
Joined: Sat May 19, 2007 8:15 pm
Gender: Male
Country: Germany

Postby el_teniente on Mon Feb 18, 2008 3:29 pm

ySQL6 is ALPHA and PHP6 is BETA(not tested by me yet)



and my Sudoku MOD must be supported by MySQL4---thanks for...help :yep:
die hard---live easy
User avatar
el_teniente
Статс-админ
Статс-админ
 
Posts: 4283
Joined: Mon Nov 07, 2005 7:51 pm
Location: Белокаменная
Gender: Male
Country: Russian Federation

Postby femu on Mon Feb 18, 2008 3:42 pm

ps. Was MySQL 6. So as it doesn't take care of the bug, it's something to report to the MySQL team I think ;-)



Have a nice day!

Felix
femu
Мастер-ковбой
Мастер-ковбой
 
Posts: 84
Joined: Sat May 19, 2007 8:15 pm
Gender: Male
Country: Germany

Postby el_teniente on Mon Feb 18, 2008 9:22 pm

femu wrote:... Was MySQL 6. So as it doesn't take care of the bug, it's something to report to the MySQL team I think ;-)...




latest versions of MySQL5 don't care of that bug too winkk:::
die hard---live easy
User avatar
el_teniente
Статс-админ
Статс-админ
 
Posts: 4283
Joined: Mon Nov 07, 2005 7:51 pm
Location: Белокаменная
Gender: Male
Country: Russian Federation


Return to Sudoku MOD

Who is online

Users browsing this forum: No registered users and 1 guest


Page generation time 0.09 sec (PHP: 78% - SQL: 22%) - DB queries 28 - Peak memory usage 4.37 MB
cron