Sign up ×
Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute:

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.

share|improve this question

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

share|improve this answer
    
Thanks for quick reply. Charsets are the same. They are both UTF8. – R3b3cca Jun 19 at 15:58
    
did you check if php.ini has the same charset ? see stackoverflow.com/questions/9351694/… – Tarciso Junior Jun 19 at 16:08
    
On the database severs? The php code is executed on a separate server to the databases. – R3b3cca Jun 19 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 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 :) – R3b3cca Jun 22 at 9:01

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.