471,888 Members | 2,433 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,888 software developers and data experts.

Php retreiving data from mssql and special characters

Hi...not sure if this is the right group for this posting, but i'm
don't know where else to post. I've got a simple problem...I have a
linux box running apache 2.0 and php5. I'm trying to use the mssql
functions in php to retreive data from a mssql server 2k. I'm pulling
data from the customers table in the northwind db and i'm getting
strange characters instead of special characters. Below is a sample
output:

(where the quotes are i get a question mark)
What I'm getting:

ALFKI - Alfreds Futterkiste - Maria Anders
ANATR - Ana Trujillo Emparedados y helados - Ana Trujillo
ANTON - Antonio Moreno Taquer?a - Antonio Moreno
AROUT - Around the Horn - Thomas Hardy
BERGS - Berglunds snabbk?p - Christina Berglund
What I should get:

ALFKI - Alfreds Futterkiste - Maria Anders
ANATR - Ana Trujillo Emparedados y helados - Ana Trujillo
ANTON - Antonio Moreno Taquería - Antonio Moreno
AROUT - Around the Horn - Thomas Hardy
BERGS - Berglunds snabbköp - Christina Berglund

Jul 11 '06 #1
8 10405
eu*****@iatmgu.com wrote:
Hi...not sure if this is the right group for this posting, but i'm
don't know where else to post. I've got a simple problem...I have a
linux box running apache 2.0 and php5. I'm trying to use the mssql
functions in php to retreive data from a mssql server 2k. I'm pulling
data from the customers table in the northwind db and i'm getting
strange characters instead of special characters. Below is a sample
output:

(where the quotes are i get a question mark)
What I'm getting:

ALFKI - Alfreds Futterkiste - Maria Anders
ANATR - Ana Trujillo Emparedados y helados - Ana Trujillo
ANTON - Antonio Moreno Taquer?a - Antonio Moreno
AROUT - Around the Horn - Thomas Hardy
BERGS - Berglunds snabbk?p - Christina Berglund
What I should get:

ALFKI - Alfreds Futterkiste - Maria Anders
ANATR - Ana Trujillo Emparedados y helados - Ana Trujillo
ANTON - Antonio Moreno Taquería - Antonio Moreno
AROUT - Around the Horn - Thomas Hardy
BERGS - Berglunds snabbköp - Christina Berglund
What charset are you using for your page? And what does the page source
show?

Probably alt.html might have been a better group to start, but this one
is a logical choice.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Jul 11 '06 #2
Thanks for the reply....

I've tried utf-8 and ISO 8859-1 but I either get empty squares or
question marks.
The html source shows question marks as well. I'm guessing, but I think
the problem may be that the mssql module is not able to handle the
chars or something with the apache config. When I run the same script
on win2k3 server with php and iis6 the characters show without a
problem.

Jerry Stuckle wrote:
eu*****@iatmgu.com wrote:
Hi...not sure if this is the right group for this posting, but i'm
don't know where else to post. I've got a simple problem...I have a
linux box running apache 2.0 and php5. I'm trying to use the mssql
functions in php to retreive data from a mssql server 2k. I'm pulling
data from the customers table in the northwind db and i'm getting
strange characters instead of special characters. Below is a sample
output:

(where the quotes are i get a question mark)
What I'm getting:

ALFKI - Alfreds Futterkiste - Maria Anders
ANATR - Ana Trujillo Emparedados y helados - Ana Trujillo
ANTON - Antonio Moreno Taquer?a - Antonio Moreno
AROUT - Around the Horn - Thomas Hardy
BERGS - Berglunds snabbk?p - Christina Berglund
What I should get:

ALFKI - Alfreds Futterkiste - Maria Anders
ANATR - Ana Trujillo Emparedados y helados - Ana Trujillo
ANTON - Antonio Moreno Taquería - Antonio Moreno
AROUT - Around the Horn - Thomas Hardy
BERGS - Berglunds snabbköp - Christina Berglund

What charset are you using for your page? And what does the page source
show?

Probably alt.html might have been a better group to start, but this one
is a logical choice.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Jul 11 '06 #3
Mel
On 2006-07-11 23:25:45 +1000, eu*****@iatmgu.com said:
Thanks for the reply....

I've tried utf-8 and ISO 8859-1 but I either get empty squares or
question marks.
The html source shows question marks as well. I'm guessing, but I think
the problem may be that the mssql module is not able to handle the
chars or something with the apache config. When I run the same script
on win2k3 server with php and iis6 the characters show without a
problem.

Jerry Stuckle wrote:
>eu*****@iatmgu.com wrote:
>>Hi...not sure if this is the right group for this posting, but i'm
don't know where else to post. I've got a simple problem...I have a
linux box running apache 2.0 and php5. I'm trying to use the mssql
functions in php to retreive data from a mssql server 2k. I'm pulling
data from the customers table in the northwind db and i'm getting
strange characters instead of special characters. Below is a sample
output:

(where the quotes are i get a question mark)
What I'm getting:

ALFKI - Alfreds Futterkiste - Maria Anders
ANATR - Ana Trujillo Emparedados y helados - Ana Trujillo
ANTON - Antonio Moreno Taquer?a - Antonio Moreno
AROUT - Around the Horn - Thomas Hardy
BERGS - Berglunds snabbk?p - Christina Berglund
What I should get:

ALFKI - Alfreds Futterkiste - Maria Anders
ANATR - Ana Trujillo Emparedados y helados - Ana Trujillo
ANTON - Antonio Moreno Taquería - Antonio Moreno
AROUT - Around the Horn - Thomas Hardy
BERGS - Berglunds snabbköp - Christina Berglund

What charset are you using for your page? And what does the page source
show?

Probably alt.html might have been a better group to start, but this one
is a logical choice.

--
================= Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
=================
Grasping at straws, but have you checked the collation setting on the
MSSQL server?

Jul 11 '06 #4
eu*****@iatmgu.com wrote:
Hi...not sure if this is the right group for this posting, but i'm
don't know where else to post. I've got a simple problem...I have a
linux box running apache 2.0 and php5. I'm trying to use the mssql
functions in php to retreive data from a mssql server 2k. I'm pulling
data from the customers table in the northwind db and i'm getting
strange characters instead of special characters. Below is a sample
output:
The text columns in the Northwind database are all nvarchar/ntext--i.e.
Unicode. These have to be flatten into an 8-bit encoding, since the
libraries used by the mssql extension can't handle Unicode (nor can PHP
itself for that matter).

On Windows, I believe the encoding is determined by the current locale.
On Linux, it's set in freetds.conf.

Jul 11 '06 #5
Thank you all for the reply...

How do I flatten into an 8-bit encoding...?
Chung Leong wrote:
eu*****@iatmgu.com wrote:
Hi...not sure if this is the right group for this posting, but i'm
don't know where else to post. I've got a simple problem...I have a
linux box running apache 2.0 and php5. I'm trying to use the mssql
functions in php to retreive data from a mssql server 2k. I'm pulling
data from the customers table in the northwind db and i'm getting
strange characters instead of special characters. Below is a sample
output:

The text columns in the Northwind database are all nvarchar/ntext--i.e.
Unicode. These have to be flatten into an 8-bit encoding, since the
libraries used by the mssql extension can't handle Unicode (nor can PHP
itself for that matter).

On Windows, I believe the encoding is determined by the current locale.
On Linux, it's set in freetds.conf.
Jul 11 '06 #6
Discovered more information:

I changed my code from using
$dbh = DB::connect("mssql://sa:pa******@192.168.0.1/northwind"); to
simply using the freetds connection

putenv("FREETDSCONF=/etc/freetds.conf");
$db=mssql_connect("MyServer2k","sa","password");

(freetds.conf setting)
[MyServer2k]
host = 192.168.0.1
port = 1433
tds version = 8.0

when the script runs now I get this error:

Warning: mssql_query() [function.mssql-query]: WARNING! Some
character(s) could not be converted into client's character set.
Unconverted bytes were changed to question marks ('?'). (severity 16)
in /var/www/test/testing/index.php on line 31

Same problem just wanted to add to it for other to see.
deciacco wrote:
Thank you all for the reply...

How do I flatten into an 8-bit encoding...?
Chung Leong wrote:
eu*****@iatmgu.com wrote:
Hi...not sure if this is the right group for this posting, but i'm
don't know where else to post. I've got a simple problem...I have a
linux box running apache 2.0 and php5. I'm trying to use the mssql
functions in php to retreive data from a mssql server 2k. I'm pulling
data from the customers table in the northwind db and i'm getting
strange characters instead of special characters. Below is a sample
output:
The text columns in the Northwind database are all nvarchar/ntext--i.e.
Unicode. These have to be flatten into an 8-bit encoding, since the
libraries used by the mssql extension can't handle Unicode (nor can PHP
itself for that matter).

On Windows, I believe the encoding is determined by the current locale.
On Linux, it's set in freetds.conf.
Jul 11 '06 #7
deciacco wrote:
Discovered more information:

I changed my code from using
$dbh = DB::connect("mssql://sa:pa******@192.168.0.1/northwind"); to
simply using the freetds connection

putenv("FREETDSCONF=/etc/freetds.conf");
$db=mssql_connect("MyServer2k","sa","password");

(freetds.conf setting)
[MyServer2k]
host = 192.168.0.1
port = 1433
tds version = 8.0
Try adding the line

client charset = cp1250

or
client charset = utf8

Jul 11 '06 #8
That did it!!!

I don't quite understand how it works or why I needed to use the php
function putenv() but it works...

I added the line marked by -->

[MyServer2k]
host = 192.168.0.1
port = 1433
tds version = 8.0
-- client charset = UTF-8

and I went back to using PEAR:

$dbh = DB::connect("mssql://sa:password@MyServer2K/northwind");

Thank you!!

Chung Leong wrote:
deciacco wrote:
Discovered more information:

I changed my code from using
$dbh = DB::connect("mssql://sa:pa******@192.168.0.1/northwind"); to
simply using the freetds connection

putenv("FREETDSCONF=/etc/freetds.conf");
$db=mssql_connect("MyServer2k","sa","password");

(freetds.conf setting)
[MyServer2k]
host = 192.168.0.1
port = 1433
tds version = 8.0

Try adding the line

client charset = cp1250

or
client charset = utf8
Jul 11 '06 #9

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Anas M. Nebuchadnezzar XXXVII | last post: by
16 posts views Thread by ram0812 | last post: by
4 posts views Thread by kenneth.osenbroch | last post: by
reply views Thread by Marc Scheuner | last post: by
12 posts views Thread by Todd Michels | last post: by
13 posts views Thread by Tom Andrecht | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.