Skip to Content.
Sympa Menu

freetds - [freetds] String comparisons not working correctly, FreeTDS + PHP + MSSQL 2005

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "Federico Cáceres" <fede.caceres AT gmail.com>
  • To: freetds AT lists.ibiblio.org
  • Subject: [freetds] String comparisons not working correctly, FreeTDS + PHP + MSSQL 2005
  • Date: Wed, 30 Apr 2008 10:44:51 -0300

Hello, I am using freetds along with PHP in a CentOS 5.0 machine.

I installed freetds and php-mssql without any problems thanks to yum,
which took care of downloading and installing both packages for me.
Then I added my host to freeTDS's config file and everything went
"marvellously", all my queries work and I was just happy everything
went so smoothly!

Suddenly, a day after the installation, some of my php queries where
not working. Later on I discovered it had something to do with the
string columns, seems like freetds was grabbing the maximun length of
the column, instead of the used length.

Let me give you an example:
column "UweName" is of type nvarchar(15),
if I run sometying like
SELECT * FROM dbo.USERWEB WHERE UweName = 'Fred';

I get no results, even if I have actually populated the database with
an entry with that name.

So, I deleted the WHERE clause, and used php's var_dump function on
each row that was retrieved from the database. And this is what i got:
"UweName" => "Fred " (The actual value, and trailing spaces
to fill the 15 characters of the column).

This is odd, specially because one day before the queries where
working marvellously (I discovered too that the MSSQL server was shut
down during the whole night after the installation and powered back on
the next morinng... the same morning in which these problems
appeared).

So, any ideas on what can be happening? Because now I'm about to do
some ugly hacking on my queries to get these working... and I'm not
happy with those.

Software versions:
PHP 5.1.6.
FreeTDS .064
Microsoft SQL Server 2005 on a Windows machine.

Thank you very much for your assistance!!!




Archive powered by MHonArc 2.6.24.

Top of Page