[MySQL/PHP] Speciale Tekens importeren

Pagina: 1
Acties:

Onderwerpen


Acties:
  • 0 Henk 'm!

  • ou812
  • Registratie: Februari 2002
  • Laatst online: 18:13
Ik probeer een textfile te importeren met data welke er als volgt uitziet:

™DeathRow|jam,1516,1516,236,138,100 enz ...
middels deze code in php:

mysql_query('LOAD DATA LOCAL INFILE "smm_statsme.txt" REPLACE INTO TABLE nuked_css_stats FIELDS TERMINATED BY "," LINES TERMINATED BY "\\n";') or die('Error loading data file.<br>' . mysql_error());

echter als ik de gegevens daarna weer opvraag via de website dan komt het er zo uit te zien:

â„¢DeathRow|jam 1516 05h:34m 236 138 100 enz ...

Heb al van alles gezocht maar krijg niet gevonden hoe ik dit kan oplossen.

Acties:
  • 0 Henk 'm!

  • Gonadan
  • Registratie: Februari 2004
  • Laatst online: 21:31

Gonadan

Admin Beeld & Geluid, Harde Waren
Misschien moet je nog even een karakterset instellen?

Het is niet altijd uitwisselbaar :)

[ Voor 35% gewijzigd door Gonadan op 16-05-2006 15:07 ]

Look for the signal in your life, not the noise.

Canon R6 | 50 f/1.8 STM | 430EX II
Sigma 85 f/1.4 Art | 100-400 Contemporary
Zeiss Distagon 21 f/2.8


Acties:
  • 0 Henk 'm!

  • ou812
  • Registratie: Februari 2002
  • Laatst online: 18:13
Zoiets dacht ik al, alleen hoe en welke charset dan? Wil niet lui overkomen maar heb echt al 3 uur lopen zoeken ofzo.

Acties:
  • 0 Henk 'm!

  • Gonadan
  • Registratie: Februari 2004
  • Laatst online: 21:31

Gonadan

Admin Beeld & Geluid, Harde Waren
Dan moet je even uitzoeken welke indeling je bestand heeft.
En dan moet je je tabel dezelfde indeling geven :)

Look for the signal in your life, not the noise.

Canon R6 | 50 f/1.8 STM | 430EX II
Sigma 85 f/1.4 Art | 100-400 Contemporary
Zeiss Distagon 21 f/2.8


Acties:
  • 0 Henk 'm!

  • ou812
  • Registratie: Februari 2002
  • Laatst online: 18:13
™DeathRow|jam,STEAM_0:0:488045,1516,236,138,0,5248,950,100,1,32334,128,212,56,263,171,60,33,0,20094,2006/05/15-22:40.42,1,24,37,5,9,0,0,0,0,0,0,0,106,70,112,51,0,0,0,0,29,137,95

En dan nog 166 meer regels (logstats van CSS)

in een txt bestandje, hoe kan ik dan zien in welke indeling het is?

Hier een link naar het volledige bestand:

http://www.team-deathrow.nl/smm_statsme.txt

Acties:
  • 0 Henk 'm!

  • zwippie
  • Registratie: Mei 2003
  • Niet online

zwippie

Electrons at work

Het lijkt me dat je bestand in UTF-8 is opgeslagen, probeer het maar eens in Firefox te bekijken en dan bij menu Beeld->Tekenset instellen op Unicode (UTF-8).

How much can you compute with the "ultimate laptop" with 1 kg of mass and 1 liter of volume? Answer: not more than 10^51 operations per second on not more than 10^32 bits.


Acties:
  • 0 Henk 'm!

  • Gonadan
  • Registratie: Februari 2004
  • Laatst online: 21:31

Gonadan

Admin Beeld & Geluid, Harde Waren
Yup, het is UTF-8 :)

http://www.gonadan.com/text.txt
En daar vind je hem in het Latin 1 formaat.
Ik heb hem even omgezet :)

[ Voor 159% gewijzigd door Gonadan op 16-05-2006 15:59 ]

Look for the signal in your life, not the noise.

Canon R6 | 50 f/1.8 STM | 430EX II
Sigma 85 f/1.4 Art | 100-400 Contemporary
Zeiss Distagon 21 f/2.8


Acties:
  • 0 Henk 'm!

  • ou812
  • Registratie: Februari 2002
  • Laatst online: 18:13
PHP:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
DROP TABLE IF EXISTS `nuked_css_stats`;
CREATE TABLE `nuked_css_stats` (
  `player_name` text character set utf8 NOT NULL,
  `steam_id` varchar(50) NOT NULL default '',
  `points` int(50) NOT NULL default '0',
  `kills` int(50) NOT NULL default '0',
  `deaths` int(50) NOT NULL default '0',
  `team_kills` int(50) NOT NULL default '0',
  `shots_fired` int(50) NOT NULL default '0',
  `shots_hit` int(50) NOT NULL default '0',
  `headshots` int(50) NOT NULL default '0',
  `suicides` int(50) NOT NULL default '0',
  `damage` int(50) NOT NULL default '0',
  `hit_head` int(50) NOT NULL default '0',
  `hit_leftarm` int(50) NOT NULL default '0',
  `hit_righarm` int(50) NOT NULL default '0',
  `hit_chest` int(50) NOT NULL default '0',
  `hit_stomach` int(50) NOT NULL default '0',
  `hit_leftleg` int(50) NOT NULL default '0',
  `hit_rightleg` int(50) NOT NULL default '0',
  `hit_generic` int(50) NOT NULL default '0',
  `total_time_online` varchar(50) NOT NULL default '',
  `last_connected` varchar(50) NOT NULL default '',
  `team_kills1` int(50) NOT NULL default '0',
  `bombs_planted` int(50) NOT NULL default '0',
  `bombs_dropped` int(50) NOT NULL default '0',
  `bombs_exploded` int(50) NOT NULL default '0',
  `bombs_defused` int(50) NOT NULL default '0',
  `bomb_defusal_attempts` int(50) NOT NULL default '0',
  `hostages_rescued` int(50) NOT NULL default '0',
  `hostages_touched` int(50) NOT NULL default '0',
  `hostages_killed` int(50) NOT NULL default '0',
  `hostages_all_rescued` int(50) NOT NULL default '0',
  `vip_escaped` int(50) NOT NULL default '0',
  `vip_killed` int(50) NOT NULL default '0',
  `rounds_won_ct` int(50) NOT NULL default '0',
  `rounds_lost_ct` int(50) NOT NULL default '0',
  `rounds_won_t` int(50) NOT NULL default '0',
  `rounds_lost_t` int(50) NOT NULL default '0',
  `rank` int(10) NOT NULL auto_increment,
  PRIMARY KEY  (`rank`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;


UTF8 code toegevoegd maar geen resultaat.

Output op site en in phpmyadmin blijven rare tekens.

output: http://www.team-deathrow.nl/index.php?file=CSS_Stats

[ Voor 13% gewijzigd door ou812 op 16-05-2006 16:13 ]


Acties:
  • 0 Henk 'm!

  • Gonadan
  • Registratie: Februari 2004
  • Laatst online: 21:31

Gonadan

Admin Beeld & Geluid, Harde Waren
Je hebt ook helemaal geen characterset aangegeven in je pagina.
Dan doet de browser maar wat, je kan dan niet 100% voorspellen wat hij weergeeft.

Trouwens, heb je mijn bestandje toegevoegd?
Want die laat in mijn browser wel de goede tekens zien :)

Look for the signal in your life, not the noise.

Canon R6 | 50 f/1.8 STM | 430EX II
Sigma 85 f/1.4 Art | 100-400 Contemporary
Zeiss Distagon 21 f/2.8


Acties:
  • 0 Henk 'm!

  • ou812
  • Registratie: Februari 2002
  • Laatst online: 18:13
Jouw bestandje kan ik wel toevoegen, echter dit de txt file die word na elke ronde overschreven en dus worden de stats dan geupdate.

Als ik in mijn IE de settings op utf8 zet dan laat ie het wel goed zien maar dan gaat de rest van de tekst op de site op sommige stukken de mist in.

Acties:
  • 0 Henk 'm!

  • Gonadan
  • Registratie: Februari 2004
  • Laatst online: 21:31

Gonadan

Admin Beeld & Geluid, Harde Waren
Ah ok, en wat doet hij als je in je tabel ISO-8859-1 als karakterset zet?

Look for the signal in your life, not the noise.

Canon R6 | 50 f/1.8 STM | 430EX II
Sigma 85 f/1.4 Art | 100-400 Contemporary
Zeiss Distagon 21 f/2.8


Acties:
  • 0 Henk 'm!

  • ou812
  • Registratie: Februari 2002
  • Laatst online: 18:13
ISO-8859-1 is unkown character set zegt ie

edit:

al gevonden.

[ Voor 23% gewijzigd door ou812 op 16-05-2006 16:44 ]


Acties:
  • 0 Henk 'm!

  • ou812
  • Registratie: Februari 2002
  • Laatst online: 18:13
Geen oplossing helaas.

Acties:
  • 0 Henk 'm!

  • Gonadan
  • Registratie: Februari 2004
  • Laatst online: 21:31

Gonadan

Admin Beeld & Geluid, Harde Waren
Dan moet je misschien toch je site in unicode weergeven en de vage tekentjes die je gebruikt op je site in escapes weergeven o.i.d. :)

Look for the signal in your life, not the noise.

Canon R6 | 50 f/1.8 STM | 430EX II
Sigma 85 f/1.4 Art | 100-400 Contemporary
Zeiss Distagon 21 f/2.8


Acties:
  • 0 Henk 'm!

  • ou812
  • Registratie: Februari 2002
  • Laatst online: 18:13
Opgelost met de 2 functies:

PHP:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
    function utf8_to_unicode( $str ) {
        
        $unicode = array();        
        $values = array();
        $lookingFor = 1;
        
        for ($i = 0; $i < strlen( $str ); $i++ ) {

            $thisValue = ord( $str[ $i ] );
            
            if ( $thisValue < 128 ) $unicode[] = $thisValue;
            else {
            
                if ( count( $values ) == 0 ) $lookingFor = ( $thisValue < 224 ) ? 2 : 3;
                
                $values[] = $thisValue;
                
                if ( count( $values ) == $lookingFor ) {
            
                    $number = ( $lookingFor == 3 ) ?
                        ( ( $values[0] % 16 ) * 4096 ) + ( ( $values[1] % 64 ) * 64 ) + ( $values[2] % 64 ):
                        ( ( $values[0] % 32 ) * 64 ) + ( $values[1] % 64 );
                        
                    $unicode[] = $number;
                    $values = array();
                    $lookingFor = 1;
            
                } // if
            
            } // if
            
        } // for

        return $unicode;
    
    } // utf8_to_unicode

PHP:
1
2
3
4
5
6
7
    function unicode_to_entities( $unicode ) {
        
        $entities = '';
        foreach( $unicode as $value ) $entities .= '&#' . $value . ';';
        return $entities;
        
    } // unicode_to_entities


op test pagina werkte dit dus nu ff ombouwen nog naar de site.

Acties:
  • 0 Henk 'm!

  • Gonadan
  • Registratie: Februari 2004
  • Laatst online: 21:31

Gonadan

Admin Beeld & Geluid, Harde Waren
UTF8-encode
UTF8-decode

|:(

en
HTMLentities

Soms is het zo makkelijk dat je er gewoon overheen kijkt :+

[ Voor 33% gewijzigd door Gonadan op 17-05-2006 09:26 ]

Look for the signal in your life, not the noise.

Canon R6 | 50 f/1.8 STM | 430EX II
Sigma 85 f/1.4 Art | 100-400 Contemporary
Zeiss Distagon 21 f/2.8


Acties:
  • 0 Henk 'm!

  • ou812
  • Registratie: Februari 2002
  • Laatst online: 18:13
Werkt nu ook op de site. :D

Acties:
  • 0 Henk 'm!

  • ou812
  • Registratie: Februari 2002
  • Laatst online: 18:13
Die twee functies had ik geprobeerd maar dan deed ie het toch niet hoor.

Maar met HTMLentities erbij wel LOL

[ Voor 22% gewijzigd door ou812 op 17-05-2006 09:27 ]

Pagina: 1