|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #49107 Empty string is returned as NULL
Submitted: 2009-07-30 07:53 UTC Modified: 2016-10-15 23:13 UTC
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: jochem dot blok at fasterforward dot nl Assigned:
Status: Wont fix Package: MSSQL related
PHP Version: 5.2.10 OS: Debian
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2009-07-30 07:53 UTC] jochem dot blok at fasterforward dot nl
This is the same bug as reported in bug: 39213. An empty string is returned as NULL.

Reproduce code:
$conn = mssql_connect('host','user','password', true);

mssql_query("CREATE TABLE #tmp(c VARCHAR(10) NULL)", $conn) or
die("error querying");

mssql_query("INSERT INTO #tmp VALUES('')", $conn) or die("error

$res = mssql_query("SELECT * FROM #tmp", $conn) or die("query");
$row = mssql_fetch_assoc($res);

$s = is_null($row['c']) ? 'NULL' : $row['c'];
echo "got -$s-\n";

Expected result:
var_dump($s) should print string(0) ""

Actual result:
var_dump($s) print NULL


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2009-07-30 07:56 UTC] jochem dot blok at fasterforward dot nl
Additional info:

FreeTDS (tds version 8.0), Sql Server 2005 SP3
 [2016-10-15 23:13 UTC]
-Status: Open +Status: Wont fix
 [2016-10-15 23:13 UTC]
With MSSQL being removed from PHP as of PHP7.0, and ext/mssql not having a maintainer, I'm gonna close this report as a Won't fix, until maybe one day it will find a new maintainer.

Alternatively you can use sqlsrv from Microsoft if you are on Windows, or pdo_dblib if you are on Unix.
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Sun Nov 29 01:01:25 2020 UTC