473,749 Members | 2,411 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 10556
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*******@attgl obal.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*******@attgl obal.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*******@attgl obal.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("ms sql://sa:pa******@192 .168.0.1/northwind"); to
simply using the freetds connection

putenv("FREETDS CONF=/etc/freetds.conf");
$db=mssql_conne ct("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("ms sql://sa:pa******@192 .168.0.1/northwind"); to
simply using the freetds connection

putenv("FREETDS CONF=/etc/freetds.conf");
$db=mssql_conne ct("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("ms sql://sa:password@MyS erver2K/northwind");

Thank you!!

Chung Leong wrote:
deciacco wrote:
Discovered more information:

I changed my code from using
$dbh = DB::connect("ms sql://sa:pa******@192 .168.0.1/northwind"); to
simply using the freetds connection

putenv("FREETDS CONF=/etc/freetds.conf");
$db=mssql_conne ct("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
5487
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 thing as a text element. (with all of the special characters converted) The best solution I've found so far is to do a string replace on all of the special characters. Like so: DataSet ds = new DataSet(); ds.EnforceConstraints = false;...
2
1816
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 this to convert these characters back to "<" and ">" signs. Please tell me asap.
16
2727
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 code snippet: import win32com.client const = win32com.client.constants #conn = establish SQL connection
4
6016
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 result is fine: select addrsurname from address where addrnr = 6666; HÅKANSSON
3
4089
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 which are not keyborad characters. Example chr(250), chr(254). Is there any way to send these kind of special characters through sockets? Is any examples available?
0
1251
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"; Response.Charset = "utf-8";
12
2663
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. Valid expressions are constants, constant expressions, and (in some contexts) variables. Column names are not permitted. (severity 15) in "Myfile"
0
1767
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 MSSQL server using freetds 8.0 and able to run queries to MSSQL server, but the query doesn't fetch anything when it runs on a column having datatype as VARCHAR having special character as in <méxico> (note the second character) the acute accent. ...
13
3591
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 removed" on the decryption piece. From everything I can see, I am doing things correctly here My code is as follows: private const string PassStr = "MyPrivateKey"; private static readonly byte PassSalt = new byte { Byte Byte Byte Byte Byte};...
0
8996
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8832
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9566
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9333
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6800
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6078
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4608
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4879
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2217
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.