MadTechie Posted August 13, 2009 Share Posted August 13, 2009 $Chunks = ceil(count($all_players_data / $MaxChunk)); should be $Chunks = ceil(count($all_players_data)/ $MaxChunk); Quote Link to comment Share on other sites More sharing options...
Aravinthan Posted August 13, 2009 Author Share Posted August 13, 2009 Hi, it inserted 583 Data and it says: Cannot inset/update table!MySQL server has gone away Quote Link to comment Share on other sites More sharing options...
MadTechie Posted August 13, 2009 Share Posted August 13, 2009 maybe add a sleep(15), or reduce the 500 to 100 Quote Link to comment Share on other sites More sharing options...
Aravinthan Posted August 13, 2009 Author Share Posted August 13, 2009 Whats sleep(15) ? Â Well changed it to 100, and it inserted 734 datas.... Quote Link to comment Share on other sites More sharing options...
MadTechie Posted August 13, 2009 Share Posted August 13, 2009 add foreach($chunk_all_players_data as $chunk_players_data) { sleep(5); //ADD this will pause the script for 5 seconds (giving MySQL a rest) Quote Link to comment Share on other sites More sharing options...
Aravinthan Posted August 14, 2009 Author Share Posted August 14, 2009 Thank you sooooooo much!!! Â It works!!!! Quote Link to comment Share on other sites More sharing options...
Aravinthan Posted August 14, 2009 Author Share Posted August 14, 2009 Man what is with me and bad news?   Anyways, I tought it did well, until I saw that there was 4 datas missing. Yeah, there is supossed to be 3500 and there is only 3496.  And it is not at the end, but somewhere in the middle. I managed to find, where one of data has not been inserted.  THe data, with id 2476 has been inserted. But the datas 2477, has been skipped... And it inserted the player 2478 instead...   Any idea why?  Thanks for your help,  And sorry for keep closing and re-opening this thread, Ara Quote Link to comment Share on other sites More sharing options...
Aravinthan Posted August 14, 2009 Author Share Posted August 14, 2009 And I also found out what case it didnt enter. Line 11: goal_streak, point_streak, total_gp, suspended_games, training, weight, height, status_in_organisanization. -32 -5Â 32Â 0Â 1Â 195Â 8Â 4 But the -5, doesnt get inserted into the point_streak, instead, its the the 32 which takes his place..... Â So everything else just snowballs from there.... Quote Link to comment Share on other sites More sharing options...
Aravinthan Posted August 14, 2009 Author Share Posted August 14, 2009 AHHHHHH... Â I know why, because as you see, we split it be 2 spaces: Â Â But here: -32 -5 Only 1.... Is there a way to fix this? Because there might be other players who have the same problem.... Quote Link to comment Share on other sites More sharing options...
Aravinthan Posted August 14, 2009 Author Share Posted August 14, 2009 OK si I change: $field_data = explode('Â ', $line_data); Â To: $line_data = str_replace(' ','Â ',$line_data); $line_data = str_replace('Â Â ','Â ',$line_data); $field_data = explode('Â ', $line_data); Â But the first data of each line seems to not be inserting.... Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted August 14, 2009 Share Posted August 14, 2009 OK si I change: $field_data = explode('Â ', $line_data); Â To: $line_data = str_replace(' ','Â ',$line_data); $line_data = str_replace('Â Â ','Â ',$line_data); $field_data = explode('Â ', $line_data); But the first data of each line seems to not be inserting.... Â Use this instead: Â Â Â Â Â Â $line_data = str_replace(' -', 'Â -', $line_data); Â Â Â Â Â Â $field_data = explode('Â ', $line_data); Quote Link to comment Share on other sites More sharing options...
Aravinthan Posted August 14, 2009 Author Share Posted August 14, 2009 Hi, The data seems to be well inserted, But there is still 4 players in the middle that doesnt get inserted. The 2476 gets inserted, but not the 2477.... And it inserts the 2478 right after 2476.... Quote Link to comment Share on other sites More sharing options...
Aravinthan Posted August 14, 2009 Author Share Posted August 14, 2009 OK I searched the DB, and his id is 902... Â Doesnt make any sens. Â I put a id field, with an auto_incriment feautre.... So it is supposed to go one by one..... Â Any idea why it might be messing up? Â Â EDIT: Â I think I might know why, there is 3 or 4 Sean Collins, but like the code Updates, when there is already one, it doesnt insert the other ones.... Man this is annoying.... Any way to work around it? Quote Link to comment Share on other sites More sharing options...
Aravinthan Posted August 14, 2009 Author Share Posted August 14, 2009 Maybe split the Update and Insert into 2 different pages? Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted August 14, 2009 Share Posted August 14, 2009 There are duplicate entries in player.txt  You have three entries for Sean Collins, and two entries for Adam Courchaine and for Trevor Lewis. This is why it skips some entries. Quote Link to comment Share on other sites More sharing options...
Aravinthan Posted August 14, 2009 Author Share Posted August 14, 2009 Yeah, So, what do you propose? Â Split it into 2 switch cases? OR 2 different pages? Quote Link to comment Share on other sites More sharing options...
Aravinthan Posted August 14, 2009 Author Share Posted August 14, 2009 Or Maybe search for the players using the id instead of name? Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted August 15, 2009 Share Posted August 15, 2009 EDIT IGNORE THIS COMPLETELY F'D UP Quote Link to comment Share on other sites More sharing options...
Aravinthan Posted August 15, 2009 Author Share Posted August 15, 2009 After inserting 2476, It sends out: Cannot inset/update table!You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 19 Â This error.... Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted August 15, 2009 Share Posted August 15, 2009 Ignore the post I made earlier. I messed up. Undo the changes I told you to do. Quote Link to comment Share on other sites More sharing options...
Aravinthan Posted August 15, 2009 Author Share Posted August 15, 2009 Ok Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted August 15, 2009 Share Posted August 15, 2009 Ok fixed my mistake now. First drop your existing players table. I have modified the table.  Replace this line (`id` INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY,  With (`id` INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY, `player_id` VARCHAR( 32 ) NOT NULL,  Change foreach($chunk_all_players_data as $chunk_players_data) To $row_id = 1; foreach($chunk_all_players_data as $chunk_players_data)  Now change   // check to see if the player already exist   $player_name = sql_safe($player_data[13]);   $user_exists_sql = "SELECT `name` FROM `$player_table_name` WHERE `name`=$player_name ";   $result = mysql_query($user_exists_sql) or die('Error checking user!<br />'.mysql_error());   // if the user does not exist, use an INSERT STATEMENT   // we'll add the user into the database   if(mysql_num_rows($result) == '0')    {      $sql = "INSERT INTO `$player_table_name` SET ";      $update_user = false;    } to     // check to see if the player already exist     $player_id = md5($player_data[13] . $row_id++);     $user_exists_sql = "SELECT `player_id` FROM `$player_table_name` WHERE `player_id`='$player_id'";     $result = mysql_query($user_exists_sql) or die('Error checking user!<br />'.mysql_error());     // if the user does not exist, use an INSERT STATEMENT     // we'll add the user into the database     if(mysql_num_rows($result) == 0)     {        $sql = "INSERT INTO `$player_table_name` SET `player_id`='$player_id', ";        $update_user = false;     }  All 3500 records should get inserted.   Quote Link to comment Share on other sites More sharing options...
Aravinthan Posted August 15, 2009 Author Share Posted August 15, 2009 EDIT: IGNORE THIS Quote Link to comment Share on other sites More sharing options...
Aravinthan Posted August 15, 2009 Author Share Posted August 15, 2009 It works thank you su much!!!! Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted August 15, 2009 Share Posted August 15, 2009 We got there finally! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.