Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [SQL] Cos nie tak ze strona kodowa, znaczki typu: Â
wozniak
post 7.08.2007, 20:27:30
Post #1





Grupa: Zarejestrowani
Postów: 278
Pomógł: 0
Dołączył: 21.11.2003

Ostrzeżenie: (0%)
-----


Witam, mam taki problem mam plik sql i cos chyba nie tak sie zrobiło ze strona kodowa tak wyglada kawałem tekstu:
(2, 1, 'Sto³y do pracy', '') skad ten znak  jak to naprawic? Ked pokazuje ze strona kodowa do UTF-8
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 12)
Cysiaczek
post 7.08.2007, 20:36:50
Post #2





Grupa: Moderatorzy
Postów: 4 465
Pomógł: 137
Dołączył: 26.03.2004
Skąd: Gorzów Wlkp.




Zaraz po połaczeniu z bazą danych wywołaj zapytanie
  1. SET NAMES UTF-8


Pozdrawiam.


--------------------
To think for yourself you must question authority and
learn how to put yourself in a state of vulnerable, open-mindedness;
chaotic, confused, vulnerability, to inform yourself.
Think for yourself. Question authority.
Go to the top of the page
+Quote Post
wozniak
post 7.08.2007, 21:12:20
Post #3





Grupa: Zarejestrowani
Postów: 278
Pomógł: 0
Dołączył: 21.11.2003

Ostrzeżenie: (0%)
-----


pokazał sie błąd

Błąd
zapytanie SQL:

SET NAMES UTF -8

MySQL zwrócił komunikat:

#1193 - Unknown system variable 'NAMES'
Go to the top of the page
+Quote Post
Zyryx
post 7.08.2007, 21:14:25
Post #4





Grupa: Zarejestrowani
Postów: 33
Pomógł: 0
Dołączył: 3.06.2006
Skąd: Gdynia

Ostrzeżenie: (0%)
-----


ma być utf-8 bez spacji przed myślnikiem smile.gif


--------------------
Pozdr. Zyryx
Go to the top of the page
+Quote Post
wozniak
post 7.08.2007, 21:18:19
Post #5





Grupa: Zarejestrowani
Postów: 278
Pomógł: 0
Dołączył: 21.11.2003

Ostrzeżenie: (0%)
-----


TEz tak wpisuje. Moze zle robie wchodze w phpmyadmin pozniej sql-> i wklejam SET NAMES UTF-8
Go to the top of the page
+Quote Post
Cysiaczek
post 7.08.2007, 21:21:00
Post #6





Grupa: Moderatorzy
Postów: 4 465
Pomógł: 137
Dołączył: 26.03.2004
Skąd: Gorzów Wlkp.




To nie tak. To robisz z poziomy skryptu php, nie w phpMyAdminie ; )

Pozdrawiam.


--------------------
To think for yourself you must question authority and
learn how to put yourself in a state of vulnerable, open-mindedness;
chaotic, confused, vulnerability, to inform yourself.
Think for yourself. Question authority.
Go to the top of the page
+Quote Post
wozniak
post 7.08.2007, 21:22:29
Post #7





Grupa: Zarejestrowani
Postów: 278
Pomógł: 0
Dołączył: 21.11.2003

Ostrzeżenie: (0%)
-----


Znaczy sie jak? sql("SET NAMES UTF-8 "); questionmark.gif?
Go to the top of the page
+Quote Post
Cysiaczek
post 7.08.2007, 21:23:45
Post #8





Grupa: Moderatorzy
Postów: 4 465
Pomógł: 137
Dołączył: 26.03.2004
Skąd: Gorzów Wlkp.




Tak. Potem już możesz pisać kolejne zapytania i baza będzie odpowiadała w utf-8 ;]


--------------------
To think for yourself you must question authority and
learn how to put yourself in a state of vulnerable, open-mindedness;
chaotic, confused, vulnerability, to inform yourself.
Think for yourself. Question authority.
Go to the top of the page
+Quote Post
wozniak
post 7.08.2007, 21:41:50
Post #9





Grupa: Zarejestrowani
Postów: 278
Pomógł: 0
Dołączył: 21.11.2003

Ostrzeżenie: (0%)
-----


pogorszyło sie:(
  1. Stó³ roboczy

  1. <? 
  2.  
  3. function my_connection() { 
  4.  
  5. global $conn; 
  6. if($conn) { 
  7. return $conn; 
  8. } else { 
  9. $conn = mysql_connect("localhost", "Wozniak", "1123491"); 
  10. if (!$conn || !mysql_select_db("sklep", $conn)) { 
  11. return 0; 
  12. } else { 
  13. return $conn; 
  14. } 
  15. }  
  16. } 
  17.  
  18. function sql($query) { 
  19. if(!($conn = my_connection())) { 
  20. return 0; 
  21. } else { 
  22. $result = mysql_query($query, $conn); 
  23. if(!$result) { 
  24. print('<div style="font: 10pt Verdana; color: white;">Wystąpił
  25.  błąd<br></div>'); 
  26. } else { 
  27. return $result; 
  28. } 
  29. } 
  30. } 
  31.  
  32.  
  33.  
  34. sql("SET NAMES utf-8"); 
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41. ?>


Ten post edytował wozniak 7.08.2007, 21:45:01
Go to the top of the page
+Quote Post
Sokal
post 7.08.2007, 21:44:49
Post #10





Grupa: Zarejestrowani
Postów: 237
Pomógł: 1
Dołączył: 8.02.2007

Ostrzeżenie: (10%)
X----


A masz w <head> ustawione kodowanie ? snitch.gif


--------------------
Jabber/E-Mail: dominiksokal[at]gmail.com | GG: #3795571
Go to the top of the page
+Quote Post
wozniak
post 7.08.2007, 21:53:00
Post #11





Grupa: Zarejestrowani
Postów: 278
Pomógł: 0
Dołączył: 21.11.2003

Ostrzeżenie: (0%)
-----


  1. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2" />
Go to the top of the page
+Quote Post
Sokal
post 7.08.2007, 21:57:58
Post #12





Grupa: Zarejestrowani
Postów: 237
Pomógł: 1
Dołączył: 8.02.2007

Ostrzeżenie: (10%)
X----


Lol, to ustaw UTF-8


--------------------
Jabber/E-Mail: dominiksokal[at]gmail.com | GG: #3795571
Go to the top of the page
+Quote Post
Cysiaczek
post 7.08.2007, 21:59:08
Post #13





Grupa: Moderatorzy
Postów: 4 465
Pomógł: 137
Dołączył: 26.03.2004
Skąd: Gorzów Wlkp.




Zobacz na jakim kodowaniu i na jakim systemi porównań działa baza, bo może sie okazać, ze na innym niż utf-8. Ewentualnie - jeśli dodawałeś dane w innym kodowaniu niż działa baza, to problem jest większy - będziesz musiał albo dodać dane od nowa, albo jakoś je skonwertowac na właściwe kodowanie.
Najpierw upewnij się, że baza działa na utf-8, potem, że strona www ma kodowanie utf-8 i na koniec oczywiście to zapytanie, które Ci podałem na początku. Dodaj nowe dane do bazy i zobacz efekt.

Pozdrawiam.


--------------------
To think for yourself you must question authority and
learn how to put yourself in a state of vulnerable, open-mindedness;
chaotic, confused, vulnerability, to inform yourself.
Think for yourself. Question authority.
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 14.08.2025 - 04:12