php.net |  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
Votes:3
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
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
31 - 25 = ?
Subscribe to this entry?

 
 [2009-07-30 07:53 UTC] jochem dot blok at fasterforward dot nl
Description:
------------
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
querying");

$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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

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] kalle@php.net
-Status: Open +Status: Wont fix
 [2016-10-15 23:13 UTC] kalle@php.net
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-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 10:01:26 2024 UTC