-1

I have a problem, very very picky.

I have a LAMP server which is connected to an IBM i (AS400) throught unixODBC. PHP execute sql on IBM i throught ODBC connection on IBM i.

I want to do a simple SELECT in my databse. It's work very well when the script is executed by a navigator (apache), but when the script is executed by CLI (php example.php) and when i have special characters like : Ô ô é à @ etc in my record PDO return NULL. And when i execute the script in my Web browser all the special characters are okay.

I don't understand why. I put 'CHARSET=UTF-8' in my DSN PDO connection.

I think this bug is related to : iSeries Access ODBC Driver with unixodbc on Debian - Invalid UTF-8 characters being returned from iSeries because when I SELECT with HEX(field) i have the hexa from browser and CLI.

PHP latest version (7.4.6), Debian 9.

Louis
  • 9
  • 4
  • 1
    Question has not enough facts. Is the hostname that runs Apache (where the script returns the correct data) the same hostname as the one that runs your script via CLI ? Give details. Next, when you run the script via CLI, in your terminal window on Debian9, what is the *shell* and specifically what is the value of LANG variable in that shell session? – mao Jun 02 '20 at 20:13
  • I resolve this problem. It was because my shell language param was not set to utf8 and my language. – Louis Jun 03 '20 at 07:04

1 Answers1

0

As per comment thread, the cause of the issue was that when running from the command-line shell and php CLI, the shell was not correctly configured for UTF-8 for the correct locale (country etc).

mao
  • 11,321
  • 2
  • 13
  • 29