Welcome Guest, Not a member yet? Register   Sign In
Inserting special characters in database
#1

[eluser]coolcom[/eluser]
Hi

I am having trouble inserting some dansih letters into my database.
Everytime i try it just inserts a question mark (?) instead.

Here is my code:

$page_title = $this->input->post('page_title');

$route_data = array(
'fake_route' => $link,
'title' => $page_title,
'navigation_order' => $navigation_order,
'front_nav' => $front_nav,
'real_route' => 'pages/index/'.$link,
'parent_id' => $this->input->post('parent')
);

$this->db->insert('routes', $route_data);

It is the field page_title where I need special characters.

I hope you can help me solve this problem.
#2

[eluser]pistolPete[/eluser]
http://ellislab.com/forums/viewreply/532548/
#3

[eluser]coolcom[/eluser]
I have tried that but it doesn't work.

The problem in that thread is that the person gets different kinds of characters.
The only thing i get is a "?".

Also when i set my Content-type to be UTF-8, every danish characters on my website becomes question marks.
(works fine width the ISO content type)
#4

[eluser]coolcom[/eluser]
No one who have a solution?

(btw. I am using the syntax CMS if this have anything to do with it.)
#5

[eluser]Scal[/eluser]
Did you check the database encoding?
If you set you DB to use a specific encoding that doesn't recognize the "special" character you want to save, no CI/PHP code will help.
This of course unless you encode all special characters to their corresponding HTML entity which to me is not a good solution (db could be used for not only web then the HTML entities stored in your texts of your DB are useless for other purposes than web)
#6

[eluser]Phil Sturgeon[/eluser]
Take a look at my post UTF-8 support in CodeIgniter.

Should solve most of the problems. syntaxCMS should be doing this already.
#7

[eluser]coolcom[/eluser]
All the things listed in that link was done in my syntax application.

But is is so weird - When I insert the meta line "<meta http-equiv="content-type" content="text/html; charset=<?php echo config_item('charset');?>" />" my special character input just sjow up as question marks. However, when I remove the line everything seems to be fine but there are still some trouble with the input.

This is the code I have:

if($this->form_validation->run('edit_page_admin'))
{
$page_name = $this->input->post('page_name');
$page_title = $this->input->post('page_title');
$navigation_order = $this->input->post('navigation_order');

if(!$page_name)
{
$link = preg_replace('/\s\s*/', '_',$page_title);

$patterns = array('/æ/', '/ø/', '/å/');
$replacements = array('ae', 'oe', 'aa');
$link = preg_replace($patterns, $replacements, $link);

$link = strtolower($link);

} else {
$link = $page_name;
}



if ($this->input->post('front_nav') == "yes")
{
$front_nav = 1;
}
else
{
$front_nav = 0;
}

$route_data = array(
'fake_route' => $link,
'title' => $this->input->post('page_title'),
'navigation_order' => $navigation_order,
'front_nav' => $front_nav,
'real_route' => 'pages/index/'.$link,
'parent_id' => $this->input->post('parent')
);

$this->db->insert('routes', $route_data);

If i insert the meta line every danish character hard coded in the admin area will be converted to question marks. If I do not insert that line the hard coded text will display fine but everything pulled gtopm the database will look like this: "æååæ"
#8

[eluser]coolcom[/eluser]
No one who have an answer for this?
#9

[eluser]coolcom[/eluser]
I found a solution.

I just needed to reencode my .php files to UTF-8 in dreamweaver Smile




Theme © iAndrew 2016 - Forum software by © MyBB