Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Additional empty space when select text from table

Status
Not open for further replies.

jianbo

Programmer
Dec 19, 2001
78
0
0
US
Now I installed latest PHP 5.2.3 Uder IIS as ISAPI. And I use SQL server 2005.

I have a table(tbl) and in field(fd1) have some info like "ABC".
I do a select query like
$query = "select fd1 from tbl where fd1='ABC' ";
$rs = mssql_query($query);
$rel = mssql_fetch_row($rs);

Then $rel[0] give me "ABC " instead of "ABC". I don't know why it will give this additional empty space.

I use this code in PHP 4.2.3 under Apache server, it works fine against SQL server 2000.

Anyone knows the reason? Thanks,
 
From the PHP manual user comments on mssql_query():

if you have a query that returns results in mssql, but run from php using mssql_query doesn't, check if you have any nvarchar fields and convert them to text using:
convert(text,nvarchar_field).

You might check that.
 
D'oh, I guess I should read the whole question first. Sorry. You could use the trim() function to remove that extra white space, but I don't know why it would be there now but not before.

Have you tried running the 5.2.3 on IIS against the SQL server 2000 database? It may be related to the db instead of the script.
 
It is the problem of DB setting. I should check this first.
Thanks, jet!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top