php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #41736 Mixed up characters in UTF-8 database with Hebrew via FreeTDS
Submitted: 2007-06-19 10:19 UTC Modified: 2016-10-15 23:10 UTC
Votes:16
Avg. Score:4.5 ± 0.8
Reproduced:15 of 15 (100.0%)
Same Version:3 (20.0%)
Same OS:0 (0.0%)
From: www dot php dot net at landrovez dot com Assigned:
Status: Wont fix Package: MSSQL related
PHP Version: 5.2.3 OS: Fedora Core 6, Kernel: 2.6.20
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2007-06-19 10:19 UTC] www dot php dot net at landrovez dot com
Description:
------------
I'm running FreeTDS version 0.64 ( latest + stable ) connecting to mssql  2000 database.

At the FreeTDS config located at: /etc/freetds.conf I've specified 
tds version = 8.0 
client charset = UTF-8

at the related connection, so far so good. it works.

The problem starts printing the data from the database.

When the last char of the selected array that I get from the DB query is a hebrew char it moves it to the next position in the array for some reason.

It only happens when the last char is hebrew, if the last char is "." for example it works just fine.

I think its something to do with UTF-8.



Reproduce code:
---------------
$mssql = mssql_connect("SQLSERVER", "root", "PASSWORD");
$mssql_db = mssql_select_db("devel_table", $mssql);

$download_id = "1";

$download_res = mssql_query("SELECT ID, Title, Description, URL FROM tblDemo WHERE Download_ID = '$download_id'");

$download = mssql_fetch_array($download_res);

echo "<pre>"
  print_r($download[Title]);
echo "</pre>";

Expected result:
----------------
Array
(
    [0] => 1
    [ID] => 1

    [1] => THE BEST GAME IN THE WORLD
    [Title] => THE BEST GAME IN THE WORLD

    [2] => DOWNLOADS THIS GREAT GAME NOW
    [Description] => DOWNLOADS THIS GREAT GAME NOW

    [3] => http://sample.com/download.zip
    [URL] => http://sample.com/download.zip
)


Actual result:
--------------
Array
(
    [0] => 1
    [ID] => 1

    [1] => THE BEST GAME IN THE WORL
    [Title] => THE BEST GAME IN THE WORL

    [2] => DDOWNLOADS THIS GREAT GAME NO
    [Description] => DDOWNLOADS THIS GREAT GAME NO

    [3] => Whttp://sample.com/download.zip
    [URL] => Whttp://sample.com/download.zip
)

*** the title should have been at hebrew for this bug to happen, for your continence the title and description are set to English just to show the example. 

As you can see it took the LAST hebrew letter from the END of the vchar and moved it to the NEXT one by the select order.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-07-03 17:41 UTC] www dot php dot net at landroverz dot com
screenshot example: http://landroverz.com/pics/php5-mssql-bad-output-demo.jpg

The red color shows the jumping char.
The blue color shows the missing char.. which is gone somewhere.
 [2008-09-07 13:23 UTC] www dot php dot net at landrovez dot com
wadap?
 [2008-09-30 09:27 UTC] borissh at vigsm dot com
This bug isn't against PHP at all reather aginst FreeTDS see debian bug Bug#500451 .
 [2014-12-29 01:04 UTC] kalle@php.net
-Status: Assigned +Status: Open -Assigned To: fmk +Assigned To:
 [2016-10-15 23:10 UTC] kalle@php.net
-Status: Open +Status: Wont fix
 [2016-10-15 23:10 UTC] kalle@php.net
With MSSQL being removed from PHP as of PHP7.0, and ext/mssql not having a maintainer, I'm gonna close this report as a Won't fix, until maybe one day it will find a new maintainer.

Alternatively you can use sqlsrv from Microsoft if you are on Windows, or pdo_dblib if you are on Unix.
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Fri Nov 27 12:01:23 2020 UTC