|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #24752 unknown column type "uniqueidentifier", type 35
Submitted: 2003-07-22 08:29 UTC Modified: 2006-01-02 08:52 UTC
Avg. Score:5.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:1 (50.0%)
Same OS:1 (50.0%)
From: ssc at coolspot dot de Assigned:
Status: Closed Package: MSSQL related
PHP Version: 4.3.8 OS: Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: ssc at coolspot dot de
New email:
PHP Version: OS:


 [2003-07-22 08:29 UTC] ssc at coolspot dot de
If you use the combination FreeTDS 0.61 + PHP 4.3.2 to access
data on a MS SQL Server 2000, columns of type "uniqueidentifier" (type 35) or causing php to barf, and you are not able to handle them.
I got it to work after a applying a patch, that I figure out :

for ext/mssql/php_mssql.c :

--- php-4.3.2/ext/mssql/php_mssql.c     2003-05-21 02:06:41.000000000 +0200
+++ php-4.3.2-LOCAL/ext/mssql/php_mssql.c       2003-07-22 13:34:35.000000000 
@@ -800,6 +800,15 @@
                        Z_DVAL_P(result) = (double) floatcol8(offset);
                        Z_TYPE_P(result) = IS_DOUBLE;
+               case SQLUNIQUE:
+                       {
+                               int length = 16;
+                               char *data = charcol(offset);
+                               Z_STRVAL_P(result) = estrndup(data,length);
+                               Z_STRLEN_P(result) = length;
+                               Z_TYPE_P(result) = IS_STRING;
+                       }
+                       break;
                case SQLVARBINARY:
                case SQLBINARY:
                case SQLIMAGE: {

and for ext/mssql/php_mssql.h

--- php-4.3.2/ext/mssql/php_mssql.h     2003-02-09 08:49:34.000000000 +0100
+++ php-4.3.2-LOCAL/ext/mssql/php_mssql.h       2003-07-22 13:32:42.000000000 
@@ -32,7 +32,7 @@
-#define MSSQL_VERSION "7.0"
+#define MSSQL_VERSION "8.0"
 #include "sqlfront.h"
 #include "sqldb.h"
@@ -59,6 +59,7 @@
 #define DBERRHANDLE(a, b) dberrhandle(b)
 #define DBMSGHANDLE(a, b) dbmsghandle(b)
 #define DBSETOPT(a, b, c) dbsetopt(a, b, c, -1)

It works for me :
RedHat 9.0 + updates
FreeTDS 0.61 (configure --prefix=/usr/local/freetds/0.61/ --enable-msdblib 
PHP 4.3.2 (configure --prefix=/usr/local/php/4.3.2/ 
--with-mssql=/usr/local/freetds/0.61/ --without-mysql)
Windows 2000 BackOffice Server SP 4 + MS SQL Server 2000 SP 3

Perhaps +#define MSSQL_VERSION "8.0" is a bit "heavy", but looks nicer in 
phpinfo() ...

You can test it, if you fetch such a field, and then pass that value to mssql_guid_string. The output must be equal to CAST (field as CHAR(64)), where field is of the uniqueidentifier type.

Reproduce code:
$sql = "select * from tablename";
$res = mssql_query($sql);

/* causes php to barf, if you have a field of type uniqueidentifier */


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2003-07-23 11:56 UTC]
This bug has been fixed in CVS.

In case this was a PHP problem, snapshots of the sources are packaged
every three hours; this change will be in the next snapshot. You can
grab the snapshot at
In case this was a documentation problem, the fix will show up soon at

In case this was a website problem, the change will show
up on the site and on the mirror sites in short time.
Thank you for the report, and for helping us make PHP better.

 [2004-02-20 11:54 UTC] rgesse at ndigital dot com
I ran into the same problem wih the latest version of PHP and Freetds (as of Feb. 18, 2004). I found that the only way to SELECT from a uniqueidentifier field is the following: 

SELECT LEFT(CAST(uniqueidentifierfield as char(64)), 36) AS thisfield FROM table
 [2004-02-25 03:04 UTC] s dot sonnenberg at coolspot dot de
I use exactly the combination : PHP 4.3.4 + FreeTDS 0.61.2.
And we have no such problems.
Could you please send your configure strings ?
 [2004-06-08 15:44 UTC] dave at daveonline dot com
I am having a simular issue, however I am getting type (36) unknown and not 35. The SQl server is Enterprise 2000. and the field is a uniqueidentifier type. here is a line from the error:

Warning: mssql_query(): column 14 has unknown data type (36) in /opt/mysql-standard-4.0.18-pc-linux-i686/scripts/test.php on line 34

and here is the conf file
        # TDS protocol version
        tds version = 8.0

;       initial block size = 512

        # uses some fixes required for some bugged MSSQL 7.0 server that
        # return invalid data to big endian clients
        # NOTE TDS version 7.0 or 8.0 should be used instead
;       swap broken dates = no
;       swap broken money = no

        # Database server login method, if both server and domain
        # logins are enabled, domain login is tried first if a domain
        # is specified, and if that fails the server login will be used.
        # OBSOLETE
;       try server login = yes
;       try domain login = no

        # The default authentication domain, can be overridden by
        # specifying a username with a domain prefix, e.g. DOMAIN\username
        # OBSOLETE use DOMAIN\username as username
;       nt domain = WORKGROUP

        # If the server responds with different domain try that one?
        # OBSOLETE never been used
;       cross domain login = no

        # Whether to write a TDSDUMP file for diagnostic purposes
        # (setting this to /tmp is insecure on a multi-user system)
;       dump file = /tmp/freetds.log
;       debug level = 10

        # Command and connection timeouts
;       timeout = 10
;       connect timeout = 10
        # If you get out of memory errors, it may mean that your client
        # is trying to allocate a huge buffer for a TEXT field.  
        # (Microsoft servers sometimes pretend TEXT columns are
        # 4 GB wide!)   If you have this problem, try setting 
        # 'text size' to a more reasonable limit 
        text size = 64512

        host = <<DELETED>>
        port = 1433
        tds version = 8.0
 [2004-08-12 18:52 UTC] zakharm at hotmail dot com
I see that the following is in ext/mssql/php_mssql.h:

#ifdef SQLUNIQUE /* FreeTSD 0.61+ */

When configuring PHP via ./configure, is there a parameter I can send to configure to enable SQLUNIQUE?

I did get it working by removing the #ifdef & #endif, but is there another way?

My configuration:
./configure --prefix=/usr/local/freetds --with-tdsver=8.0

./configure --with-mssql=/usr/local/freetds --with-regex=php --with-config-file-path=/etc/php4/apache --disable-rpath --enable-memory-limit --disable-debug --with-layout=GNU --with-pear=/usr/share/php --with-mysql=shared  --with-apxs=/usr/bin/apxs
 [2004-08-23 21:23 UTC] ssc at coolspot dot de
Open again dudes. 
Is there somebody who needs lessons in CVS usage, 
or what ?
 [2004-08-23 21:36 UTC] ssc at coolspot dot de
Ok, once again a lesson in the usage of a really 
famous tool, called "diff", which could by new to some of 
you. A TIP : if you are searching a release manager, 
call me. It is "really" anoying to double-check 
PHP each time i need to update. 
/mssql/php_mssql.h iff -wu 
php-4.3.8.working/ext/mssql/php_mssql.h php-4.3.8/ext/ 
--- php-4.3.8.working/ext/mssql/php_mssql.h     2004-08-23 
15:56:59.000000000 +0200 
+++ php-4.3.8/ext/mssql/php_mssql.h     2004-04-21 
01:37:26.000000000 +0200 
@@ -38,7 +38,7 @@ 
 #ifndef SHORT 
-//typedef short SHORT; 
+typedef short SHORT; 
@@ -62,7 +62,9 @@ 
+#ifdef SQLUNIQUE /* FreeTSD 0.61+ */ 
 #define DBERRHANDLE(a, b) dberrhandle(b) 
 #define DBMSGHANDLE(a, b) dbmsghandle(b) 
 #define DBSETOPT(a, b, c) dbsetopt(a, b, c, -1)
 [2004-08-24 08:40 UTC]
Please keep your insulting comments in front of you.

What version doesn't work? 
 [2004-08-24 08:40 UTC]
Behave like this and receive no help.
 [2005-10-21 16:48 UTC] rodent at rodent dot za dot net
I would like to reopen this bug for php 5. The same appears to be ocurring there with freetds 0.61 from debian stable
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Jun 18 00:01:32 2024 UTC