Using PHP 5.2 and PostgreSQL database server 8.1
I run the following query from a php script:
insert into pager
(PAG_ID,PAG_PARENT,PAG_NAME,PAG_ACTIVE)
values(3000,0,'Aå cool site',1)
Note the values has been entered in a UTF8 encoded HTML page
and get this in return:
ERROR: invalid byte sequence for encoding "UTF8": 0xe3a520 '
The database encoding is in UTF8
After connecting to database in script I have also tried this:
@pg_query($this->db, "set client_encoding to 'UTF8'");
I made sure the php client HTML have proper UTF8 encoding set.
If I remove the "å" character from the insert then it works.
UPDATE:
I have checked the encoding after connecting to the database with:
pg_client_encoding($this->db)
which returns SQL_ASCII
Whatever I try to use after connecting... either:
@pg_set_client_encoding( $this->db, 'UTF8' );
or
@pg_set_client_encoding( $this->db, 'UTF8' );
or
@pg_query($this->db, "set client_encoding to 'UTF8'");
or
@pg_query($this->db, "set client_encoding to 'UTF8'");
Nothing works....
What do I have to do to make this work in PostgreSQL?
I run the following query from a php script:
insert into pager
(PAG_ID,PAG_PARENT,PAG_NAME,PAG_ACTIVE)
values(3000,0,'Aå cool site',1)
Note the values has been entered in a UTF8 encoded HTML page
and get this in return:
ERROR: invalid byte sequence for encoding "UTF8": 0xe3a520 '
The database encoding is in UTF8
After connecting to database in script I have also tried this:
@pg_query($this->db, "set client_encoding to 'UTF8'");
I made sure the php client HTML have proper UTF8 encoding set.
If I remove the "å" character from the insert then it works.
UPDATE:
I have checked the encoding after connecting to the database with:
pg_client_encoding($this->db)
which returns SQL_ASCII
Whatever I try to use after connecting... either:
@pg_set_client_encoding( $this->db, 'UTF8' );
or
@pg_set_client_encoding( $this->db, 'UTF8' );
or
@pg_query($this->db, "set client_encoding to 'UTF8'");
or
@pg_query($this->db, "set client_encoding to 'UTF8'");
Nothing works....
What do I have to do to make this work in PostgreSQL?