Welcome Guest, Not a member yet? Register   Sign In
[Solved] Postgresql and encoding problem
#1

[eluser]farbar[/eluser]
I have a db in PostgreSQL with UTF8 encoding. Also in database.php these lines exist:

Code:
$db['default']['char_set'] = "utf8";
$db['default']['dbcollat'] = "utf8_general_ci";
And in my php view page:

Code:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
But when I insert a new record with some unicode chars, following error occurs:

Code:
A Database Error Occurred

Error Number:

ERROR: invalid byte sequence for encoding "UTF8": 0xf8 HINT: This error can also happen if the byte sequence does not match the encoding expected by the server, which is controlled by "client_encoding".

SELECT * FROM "books" WHERE LOWER(name) = '�����' LIMIT 1
Please help.
#2

[eluser]farbar[/eluser]
ok
Indeed problem was not from INSERT. I use a callback function to check that field value is unique. I changed this line in callback function from
Code:
$result= $this->db->get_where('books', array('LOWER(name)' => strtolower($name)),1,0);
to
Code:
$result= $this->db->get_where('books', array('name' => $name),1,0);
and now it works fine.




Theme © iAndrew 2016 - Forum software by © MyBB