PHP PostgreSQL UTF-8 issue

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

I have problem with Unicode (UTF-8) data read from PostgreSQL 8.0, processed in PHP 4.3.5 and inserted back to DB.

Situation:
database with unicode (utf-8) encoding
table customer
  name varchar(30),
  surname varchar(50)
table invoice_tmp
  name varchar(70),
  surname varchar(70)

There are czech (utf-8 encoded) character in these columns
I have PHP script which reads data from customer and after some computings puts it to invoice_tmp. No data manipulation is done with name and surname.

The data the script reads are OK, when I print it on output I see it OK.
On most data it's OK to insert it to invoice_tmp but there are some data which it's not possible to insert.

When the name is longer than 30 bytes (not chars) or surname is longer than 50 bytes (not chars) I get the following error on insert:

Warning: odbc_exec(): SQL error: [unixODBC]Error while executing the query (non-fatal); ERROR: unterminated quoted string at or near "'hasící zařízení spol. s r" at character 74, SQL state 01000

When I print the name I see full text 'hasící zařízení spol. s r.o.'

strlen() of full text is 28 chars, 33 bytes
strlen() of trimmed (in error mgs) text is 25 chars, 30 bytes

The same error repeats for other records, every time the trimmed text has variable char lenght (depends on number of czech chars) but exactly 30 bytes (for name) or 50 bytes (for surname).

I suppose it's problem of PHP which somehow knows the size of db column and then puts only such bytes into insert command. But prints full variable. Is there some way to make it working? Use multibyte? I tried to use mb_ functions but without efect.

For now I made it working by increasing the size of the name and the surname columns in the DB.


Regards,
Martin Edlman

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux