473,320 Members | 1,946 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 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 10521
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Anas M. Nebuchadnezzar XXXVII | last post by:
I am loading an Xml file from a sql server. I have one field that contains child nodes stored as text. The problem is, when I try to imort the dataset into a XmlDataDocument, it loads the whole...
2
by: Renuka | last post by:
Hello, I have to retrive 2 columns from the database which have HTML characters like &lt; &gt; (the less than"<" and greater than sign ">")in their data. Is there any function in C# which can do...
16
by: ram0812 | last post by:
Helo guys, I am trying to query the MSSQL DB using ADO. I am not able to make the LIKE statement fetch the correct results. Can anyone tell me what I need to do to get this working? Below is the...
4
by: kenneth.osenbroch | last post by:
Hi, I have a MSSQL Server communicating with an Oracle database through a MSSQL linked server using a MS ODBC connection. If I query the Oracle database through the Oracle ODBC 32Bit Test, the...
3
by: Valli | last post by:
Hi, I want to send ascii data over the tcp socket in VB.NET. When the data reaches the destination, the special characters in the messages are recived as '?'. I meant the special characters...
0
by: Marc Scheuner | last post by:
Folks, we're trying to stream back a result set from a SQL query into Excel from our ASP.NET application. Basically, we're doing this here: Response.ContentType = "text/csv";...
12
by: Todd Michels | last post by:
Hi all, I am trying to send data from a form and insert it into a MSSQL DB. When I submit the data I get: Warning: mssql_query() : message: The name "Todd" is not permitted in this context....
0
by: hassanali20 | last post by:
I've surfed this forum and found one thread which was talking about the same problem i've, but it didn't help in my situation. http://www.thescripts.com/forum/thread510563.html I could connect to...
13
by: Tom Andrecht | last post by:
I'm trying to get some encryption/decryption routines going to take care of my data, and while the encryption is working great, I keep running into the message "Padding is invalid and cannot be...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.