Encoding madness!



Using PHP 5.1.4 with MySQL 5.0.18 on a dev machine. Doesn't seem to matter what I do, character encoding is screwed on this server. It's ok with normal chars, but "extended" chars like the pound sign (£) are corrupted when sent to the DB from a form then back to the browser from the DB. I'm setting the following headers on the top of every page (using an include, so I'm certain it's always in there):

<?xml version="1.0" encoding="utf-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
<html xmlns="http://www.w3.org/1999/xhtml"; xml:lang="en" lang="en" dir="ltr">

Also using header("Content-type: text/html; charset=ISO-8859-1"); in the include file for good measure. PHP scripts are being saved in UTF8 encoding. Server is running Linux.

If I print the data back out to the browser (selected from the DB) in place of the pound sign, I just get A£ (with an accent over the A). Bizarrely, phpmyadmin displays a pound sign correctly when viewing the rows in the table, so I assume there's some conversion going on there (probably converting accent+pound to pound or something).

It seems like the data is getting into the DB ok, but PHP is corrupting it as it comes out again.
.



Relevant Pages

  • Re: PHP Instalation problems. Browser doesnt know what to do
    ... This is loaded and run as a local server (for class ... PHP 5.2.0 from php-5.2.0-win32-installer.msi ... # configuration directives that give the server its instructions. ...
    (comp.lang.php)
  • Re: PHP Instalation problems. Browser doesnt know what to do
    ... This is loaded and run as a local server (for class ... PHP 5.2.0 from php-5.2.0-win32-installer.msi ... # configuration directives that give the server its instructions. ...
    (comp.lang.php)
  • Re: write with cURL
    ... execute permissions. ... This is assuming that the PHP script runs ... of potential security risks from other users on the same server. ... Apache as the global web server user and thus needs world write ...
    (alt.php)
  • mysqli error?
    ... I'm just setting up my php enviroment and I typed in a simple script ... # configuration directives that give the server its instructions. ...
    (comp.lang.php)
  • Re: write with cURL
    ... execute permissions. ... This is assuming that the PHP script runs ... of potential security risks from other users on the same server. ... web server itself is part of the group. ...
    (alt.php)