Welcome Guest, Not a member yet? Register   Sign In
Character Enconding + Mysql issues
#1

[eluser]Khamusa[/eluser]
Hi all,

i've been programming with PHP for a long, but I have never used any framework. I have now tried CodeIgniter, but i'm facing some issues along the development of very simple mysql tasks.

I need to save some textual information into my mysql table, but with support for latin characters, like "á", "é", and so on... What happens is that when I save these characters into mysql (using $this->db->insert('tablename', $data); in my controller) it saves the info in mysql with question marks (?) replacing these "latin special characters".

So, i try to save, for example, the text "Codeigniter é ótimo" (wich means "Codeigniter is Good") but it saves as "Codeigniter ? ?timo", got it? It's not an issue of different character-encoding on each view, but instead, the insert function SAVES INTO THE MYSQL TABLE already with all the question marks. I made a test, to see when this replacement takes place, and it is surely at the moment of the insert statement, since a simple echo function placed before the insert line displayed the correct information, without the questionmarks, and the phpmyadmin interface displays the ? when I try to view the saved information.

Ah, we have another problem. I am developing this to a client that already has a website wich is completely coded as iso-8859-1, so I can't change anything to utf-8 (although I would really like to). So I have to make it work using iso-8859-1 everywhere (I already changed config.php's default charset to iso-8859-1, and tried using $this->output->set_header("charset:iso-8859-1") before loading each view)


Can anyone help me?
I really hate encoding issues, from the first day I started programming, rs rs rs

cheers
Samuel Brandão
#2

[eluser]Prasanna[/eluser]
Hope this may help you

http://www.nicknettleton.com/zine/php/ph...cheatsheet
#3

[eluser]mattalexx[/eluser]
I'm having the same problem. Can't write a real estate site in New Mexico without being able to save the word "Cañon". Thanks you for your contribution, Prasanna. That link is really great. But it's not a solution to this problem. If I use phpMyAdmin to save these special characters, it works (including output in a browser). But if I use CI's database class, "Cañon" end up looking like "Ca?on". In other words, my database is configured correctly but I'm doing something wrong in CI.

Anyone have any suggestions?
#4

[eluser]mattalexx[/eluser]
Correction:

Okay, so this is what Codeigniter is inserting and it looks right:

Code:
UPDATE `properties`
SET `mls_lan_coverage` = 'Piñon/Juniper'
WHERE `mls` = '85812'

When I let CI do it though, it doesn't work. But when I copy/paste this SQL into a MySQL command line, it works.

Hmm.
#5

[eluser]deadelvis[/eluser]
Exact same problem here. Have you found a solution? This is driving me a bit insane.
#6

[eluser]mattalexx[/eluser]
[quote author="deadelvis" date="1245105039"]Exact same problem here. Have you found a solution? This is driving me a bit insane.[/quote]

http://www.sitepoint.com/forums/showthre...?p=4221176
#7

[eluser]deadelvis[/eluser]
hmmm thanks alex.. but since I am using the Active Record.... shouldn't CI be issuing a SET NAMES already? That's what $db['default']['char_set'] under the database config is supposed to be for. Sad
#8

[eluser]mattalexx[/eluser]
[quote author="deadelvis" date="1245109590"]shouldn't CI be issuing a SET NAMES already? That's what $db['default']['char_set'] under the database config is supposed to be for. Sad[/quote]

Yes, I don't know. Is it being called?

You might just try to call it manually to see if it makes a difference. Twice won't hurt.




Theme © iAndrew 2016 - Forum software by © MyBB