PHP在Postgresql服务器之间解释字符串的方式不同

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.

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