|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #24476 Character translation in mssql_query
Submitted: 2003-07-03 05:04 UTC Modified: 2003-08-25 02:35 UTC
From: andrea dot balducci at antos dot it Assigned:
Status: Not a bug Package: MSSQL related
PHP Version: 5.0.0b1 (beta1) OS: WINXP / WIN2000 SRV
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: andrea dot balducci at antos dot it
New email:
PHP Version: OS:


 [2003-07-03 05:04 UTC] andrea dot balducci at antos dot it
I'm trying to insert chars like ? ? ? ? ? in a sql server 2K table.
Sometimes the chars are traslated in others.

Tryed with php 4.x and 5

Reproduce code:
Table Sample:
	[a] [text] COLLATE Latin1_General_CI_AS NULL ,
	[b] [text] COLLATE SQL_Latin1_General_CP1_CI_AS NULL 

Script sample:
    $conn = mssql_connect('localhost','sa','');
    if (!mssql_select_db('mydb', $conn))
        return 0;
    mssql_query("INSERT INTO PIPPO (A,B) VALUES ('??????','??????')", $conn);

Expected result:
Select * from pippo
  A      B
------- -------
??????	??????

Actual result:
Select * from pippo
  A      B
------- -------
=?????	=?????

Using Sql Profiler i've discovered that the query issued to sql server by mssql_query has the characters already changed. So sql exec "INSERT INTO PIPPO (A,B) VALUES ('=?????','=?????')"


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2003-07-03 12:37 UTC]
I have tested the latest version of both php4 and php5 and I can't reproduce this problem.

It sounds like you are using two different methods to access the database. When PHP is used with a web server the MSSQL extension will use codepage 125x (ANSI). When called from a command line the MSSQL extension uses the DOS code page (437 for US).

The MS SQL Server client libraries can be configured to do an automatic ANSI to OEM conversion. If that option is enabled you will see the same characters from both web server and command line. If it is disabled the output will not look the same.
 [2003-07-07 04:13 UTC] andrea dot balducci at antos dot it
Done, Tnx.
 [2003-08-12 16:15 UTC] gusthac at cdlnet dot com dot br
I am with the same problem and don't have fixed this one yet. Is there another solution to solve this question? I tried this one but I got nothing. Also I tried to use the code:
setlocale(LC_CTYPE, "pt_BR");

but without success.
If possible, I would like to know other solutions.
 [2003-08-25 02:35 UTC] andrea dot balducci at antos dot it
1) Check the settings (Client Network Utility) on the machine running SqlServer (if your apps works with 2 or more servers (DB + Web))

2) Check the collation of the colums
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Jun 17 05:01:31 2024 UTC