Jump to content

Aravinthan

Members
  • Posts

    162
  • Joined

  • Last visited

    Never

Posts posted by Aravinthan

  1. 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....

  2. 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?

  3. 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....

  4. 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....

  5. Man what is with me and bad news?  :confused:

     

     

    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

  6. Ok so I change:

    $all_players_data 
    

     

    To 3500, It worked, but it doesnt insert all, there still some missing and I get the MYSQL server gone error....

     

    Now I am playing with the 3500 and MaxChunk number without any result...

  7. You lost me there... Lol

     

    OK so this is what it gives me:

    // split every 20 lines into a new array
    $all_players_data = array_chunk($players_data_file, 20);
    
    //Calculate Number of chuncks
    $MaxChunk = 500;
    $Chunks = ceil(count($all_players_data / $MaxChunk));
    
    //Break into chunks
    $chunk_all_players_data = array_chunk($all_players_data, $Chunks, true);
    
    //Loop through each chunk
    foreach($chunk_all_players_data as $chunk_players_data)
    {
    
    
    // loop through each block of 20 lines
    foreach($chunk_players_data as $player_data) //UPDATED
    {
    
    // 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;
           }
           // user does exist so we'll use an UPDATE statement
           // update the existing user
           else
           {
               $sql = "UPDATE `$player_table_name` SET ";
               $update_user = true;
        }
        // here we're looping through each line
        foreach($player_data as $line_key => $line_data)
        {
            // if we're not on line 8, 9, 10, 13, 14 or 15
            // turn line data into an array
            if(!in_array($line_key, array(7, 8, 9, 12, 13, 14)))
            {
                $field_data = explode('  ', $line_data);
    
                // match up the data with the field array
                // this is where our query is generated
                foreach($field_data as $field_key => $field_value)
                {
                    if(isset($fields[$line_key][$field_key]))
                        $sql .= "`" . $fields[$line_key][$field_key] . "`=" . sql_safe($field_value) . ', ';
                }
    
                $sql .= "\n";
            }
    // add the whole line into the query
            else
            {
                // if we're updating the user skip line 14
                if( $update_user && $line_key == 13)
                    continue;
    
                $sql .= "`" . $fields[$line_key][0] . "`=" . sql_safe($line_data) . ", \n";
            }
    
        }
    
    // remove the last three characters from $sql
        $sql  = substr($sql, 0, -3);
    
        // add the WHERE clause only if we are updating the user
        if($update_user)
            $sql .= " WHERE name=$player_name";
    
        echo '<pre>' . print_r($sql, true) . '</pre>';
    
        mysql_query($sql) or die('Cannot inset/update table!'.mysql_error());
    }
    }
    

     

    Unfortunatley, I get this error:

    Fatal error: Unsupported operand types in /home/liguehs/public_html/converter/test.php on line 141

     

  8. You are right, there is an error:

    Error checking user!

    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 'Aversa'' at line 1

     

    EDIT:

     

    I checked teh players file and the name is:

    Jonathan D'Aversa

    So thats why....

    I put addslashes()

    $player_name = addslashes(sql_safe($player_data[13]));
    

     

    But it shows me:

     

    Error checking user!

    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 '\'Milan Hnilicka\'' at line 1

     

     

    Thanks for your help,

    Ara

  9. Hi wow, thanks but can you tell where and how can I put these?:

    After, overral_draft(last data), where it takes a date in another table and it subtracts it to give is age?

     

    OA =

    (shooting + playmaking + stickhandling + checking + hitting + marking + skating + endurance + penalty + faceoff + leadership + strength + potentiel + consistency + gree) / 15

     

    OFF =

    (shooting + playmaking + stickhandling) / 3

     

    DEF =

    DEF = (checking + marking + hitting) / 3

     

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.