0

I have php code that is submitting a string to two postgresql databases on two different servers.

The string is:

'£pound €euro'

PHP Server Version:

  • PHP 5.4.36-0+deb7u3
  • Debian Linux 3.2.0-4-amd64

Server 1 version:

  • Debian Linux 2.6.32-5-amd64
  • Postgresql: 9.1.11

Server 2 version:

  • Debian Linux 2.6.32-5-amd64
  • Postgresql: 9.1.7

The server encoding for both is UTF8

The client_encoding is also UTF8

The locale for both servers are the same also.

The following code is used to execute the query:

$oConn=@pg_Connect('host=$myip dbname=$mydb user=$myuser password=$mypassword');
$sql = "select * from _myfunction($mystring)"; 
$result=@pg_query($oConn, $sql);

What I'm finding happening is that when the query is executed, the following is being received by Server 1:

select * from _myfunction('£pound €euro')

Yet on Server 2 the following is being received:

select * from _myfunction('£pound �euro')

Does anybody have a clue on where I could look to figure out what is causing the difference to the query being received between the two servers. Seeing Server 2's query is turning funky, invalid byte sequence errors in other parts of the database are causing an issue.

I'm stumped. The only difference I can see is the minor versions of postgresql.

Rebex
  • 3
  • 2

1 Answers1

0

I guess your postgree charset is not the same in both servers. See How can i change database encoding for a PostgreSQL database using sql or phpPgAdmin? , it may help you

Community
  • 1
  • 1
Tarciso Junior
  • 549
  • 9
  • 16
  • Thanks for quick reply. Charsets are the same. They are both UTF8. – Rebex Jun 19 '15 at 15:58
  • did you check if php.ini has the same charset ? see http://stackoverflow.com/questions/9351694/setting-php-default-encoding-to-utf-8 – Tarciso Junior Jun 19 '15 at 16:08
  • On the database severs? The php code is executed on a separate server to the databases. – Rebex Jun 19 '15 at 16:21
  • sorry, I though that was two different php servers, Had you tried to set charset on pg_connect ?? try force charset like $dbconn = pg_connect("host=localhost options='--client_encoding=UTF8'"); – Tarciso Junior Jun 19 '15 at 18:26
  • Yea, that's what our solution is going to be I think. I'm just frustrated that I can't figure out why two identical (except minor pg versions) database servers are getting a different result when code is submitted from one PHP server. Thanks for your help so far :) – Rebex Jun 22 '15 at 09:01