CodeIgniter Forums
WYSIWYG + Uploading special charakters into database (solved) - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forum-21.html)
+--- Thread: WYSIWYG + Uploading special charakters into database (solved) (/thread-21771.html)

Pages: 1 2


WYSIWYG + Uploading special charakters into database (solved) - El Forum - 08-20-2009

[eluser]Callista[/eluser]
In my content management system i have an WYSIWYG editor.
So the company can easily edit the text on the website pages.

But when i use special characters as: ' " ë é á etc.
it fails to upload into the database.
you get errors like:


Quote:A Database Error Occurred
Error Number: 1064

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

I get why the error is occurring (because it fails on the special character)
but i haven't found a solution to fix it (except stop using special characters but my company isn't so happy about that)

Do more people have this problem and how did you fixe it??

currently i'm using the WYSIWYG editor of: openwebware.com/


WYSIWYG + Uploading special charakters into database (solved) - El Forum - 08-20-2009

[eluser]wiredesignz[/eluser]
Phil Sturgeon wrote something that might help you with this.
UTF-8 Support for CodeIgniter

EDIT:
Other than adding headers to index.php everything there makes sense.
The CI Output class already has facility to add headers if required.


WYSIWYG + Uploading special charakters into database (solved) - El Forum - 08-20-2009

[eluser]Callista[/eluser]
[quote author="wiredesignz" date="1250781930"]Phil Sturgeon wrote something that might help you with this.
UTF-8 Support for CodeIgniter

EDIT:
Other than adding headers to index.php everything there makes sense.
The CI Output class already has facility to add headers if required.[/quote]

everything is already set to UTF-8 but thnx...

no the problem is when i insert code.
because the sentence contains a ' for example. The insert cannot be inserted...once the code is in de database it's shown correct. but getting it in the database is the problem


WYSIWYG + Uploading special charakters into database (solved) - El Forum - 08-20-2009

[eluser]sl3dg3hamm3r[/eluser]
Use either CI's active record class in order to make sure your content is properly escaped, or do it so manually: sql_real_escape_string


WYSIWYG + Uploading special charakters into database (solved) - El Forum - 08-20-2009

[eluser]Callista[/eluser]
[quote author="sl3dg3hamm3r" date="1250792668"]Use either CI's active record class in order to make sure your content is properly escaped, or do it so manually: sql_real_escape_string[/quote]

With the active record class the update is indeed processed without errors... but the special characters just disappears. That's still nog exactly what i want.

For example if i now write the word: "That's"
and i update the word is uploaded as: "Thats"
and of course i want it to be: "That's"


*EDIT*

on the normal text fields it's working for a part... it's doing the ' and " but not the é. and in the WYSIWYG editor it's not saving any special characters.
I'm going crazy! stupid editors.. i've been having trouble with those things from the start!


WYSIWYG + Uploading special charakters into database (solved) - El Forum - 08-20-2009

[eluser]Callista[/eluser]
i've got it.. YES!

at least.. i think i do.. it's working for now haha...
by ascii_to_entities()

Code:
function edit_hoofdpagina()
      {
        $naam = $this->input->post('menu_naam');    
        $status = $this->input->post('menu_status');
        $volgorde = $this->input->post('menu_volgorde');
        $subtekst = $this->input->post('menu_subtekst');
        $plaats = $this->input->post('menu_plaats');
        $ID = $this->input->post('menu_ID');

        $menu_subtekst = ascii_to_entities($subtekst);

        $data = array(
               'menu_naam' => $naam,
               'menu_status' => $status,
               'menu_volgorde' => $volgorde,
               'menu_subtekst' => $menu_subtekst,
               'menu_plaats' => $plaats
            );

        $this->db->where('menu_ID', $ID);
        $this->db->update('menu', $data);
      }

the code isn't cleaned up yet and you probably can't read half of it because of the dutch
but still it's working and i'm cheering Smile


WYSIWYG + Uploading special charakters into database (solved) - El Forum - 08-20-2009

[eluser]sl3dg3hamm3r[/eluser]
I would check as well the character-set of your DB...


WYSIWYG + Uploading special charakters into database (solved) - El Forum - 08-20-2009

[eluser]Callista[/eluser]
[quote author="sl3dg3hamm3r" date="1250798001"]I would check as well the character-set of your DB...[/quote]

it's set on UTF-8 if that's what you mean..


WYSIWYG + Uploading special charakters into database (solved) - El Forum - 08-20-2009

[eluser]sl3dg3hamm3r[/eluser]
actually yes - from there I can't see why you have such problems.


WYSIWYG + Uploading special charakters into database (solved) - El Forum - 08-21-2009

[eluser]sl3dg3hamm3r[/eluser]
Where do actually the special characters disappear? Do they make it into the DB? I remember once having problems when I set everything to utf-8 (html-encoding, DB), but the php-files weren't saved utf-8 encoded (by default, my editor was set to iso-latin). Took me quite a while to figure out.

I would check the setting of your editor as well...