Hello,
I’m using a grid with an connector which loads data from a mysql-DB.
It worked fine until I decided to change my webhoster. Now I can’t get the special German characters from the DB in my grid.
This is the connector-code from my first hoster (it works fine and displays all chars like ‘ä’):
<?php echo "<?xml version='1.0' encoding='ISO-8859-1' ?>";require("../dhtmlx/dhtmlxConnector/codebase/grid_connector.php");
$db = mysql_connect("<some login data...>");
mysql_select_db("<a db name>");
function change_stimme($row){
$stimme = $row->get_value("Stimme");
switch ($stimme) {
case 1:
$row->set_value("Stimme","Sopran");
break;
case 2:
$row->set_value("Stimme","Alt");
break;
case 3:
$row->set_value("Stimme","Tenor");
break;
case 4:
$row->set_value("Stimme","Bass");
break;
}
}
$mg = $_GET["mg"];
$sqlstr = "SELECT ";
$sqlstr.= "* ";
$sqlstr.= "FROM ";
$sqlstr.= "tblChorMitglied ";
if ($mg == 0 or $mg == 1)
{
$sqlstr.= "WHERE ";
$sqlstr.= "Aktiv ";
$sqlstr.= "= ";
$sqlstr.= $mg;
}
$sqlstr.= ";";
$grid = new GridConnector($db,"MySQL");
$grid->event->attach("beforeRender","change_stimme");
$grid->render_sql($sqlstr,"Mitglied_ID", "Mitglied_ID,Name, Vorname, Geburtsdatum, Stimme");
?>
After moving to another hoster this connector doesn’t work any more because the first line echo “<?xml version='1.0' encoding='ISO-8859-1' ?>”; is before the require-line
-> Warning: Cannot modify header information - headers already sent by…
If I do first the “require-step” and then the “echo”, it doesn’t work on both servers.
Now I tried the following solution, but it doen’t work either:
... $grid = new GridConnector($db,"MySQL"); ----> $grid->set_encoding("iso-8859-1"); $grid->event->attach("beforeRender","change_stimme"); $grid->render_sql($sqlstr,"Mitglied_ID", "Mitglied_ID,Name, Vorname, Geburtsdatum, Stimme");Where’s the point I don’t get? How can I add the right encoding information to the XML?
The characters don’t appear in the grid, but not in the XML-Output of the .php either, so it’s not a grid problem, I guess.
JayN