php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #10889 mssql_fetch_array - IDENTITY values returned as string with padded NULL chars
Submitted: 2001-05-15 17:03 UTC Modified: 2001-06-30 15:34 UTC
From: alt at swiftview dot com Assigned:
Status: Closed Package: MSSQL related
PHP Version: 4.0.5 OS: Windows 2000
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: alt at swiftview dot com
New email:
PHP Version: OS:

 

 [2001-05-15 17:03 UTC] alt at swiftview dot com
OS = Windows 2000
Server = IIS 5.0
Database = SQL Server 7
PHP = 4.0.5

To reproduce
1. Create a table as such:
    CREATE TABLE table1 (
       row_id NUMERIC(9,0) IDENTITY,
       col1 INT NOT NULL,
       col2 INT NULL,
       col3 VARCHAR(25) NULL,
      PRIMARY KEY(row_id)
    )
    GO

2. Insert a row:
    INSERT INTO table1 (col1) VALUES(1)
    GO

3. Now fetch that row
    <?php
    $hostname = "<your hostname here>";
    $username = "<your username here>";
    $password = "<your password here>";
    $dbName = "<your database name here>";

    // Connect
    $connectionID = mssql_connect($hostname, $username, $password);
    $retval = mssql_select_db($dbName);

    // Query
    $query = "SELECT row_id, col1, col2, col3 from table1"
    $queryID = mssql_query($query, $connectionID)

    // Fetch fields
    $fields = mssql_fetch_array($queryID);

    list($row_id, $col1, $col2, $col3) = $fields;

    echo "type = " . gettype($row_id) . "<br>";
    echo "strlen(\$row_id) = " . strlen($row_id) . "<br>";
    echo bin2hex($row_id) . "<br>";

    mssql_close($connectionID);
    ?>

3. Results
    Did yours match mine?  My result from bin2hex is
        310000000000000000000000000000000000000000
    The character 1, followed by 19 nulls!


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-06-30 15:34 UTC] fmk@php.net
Update to php 4.0.6, and use the php.ini setting

mssql.compatability_mode = Off

to specify that you will have all data returned as php types.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 17:01:29 2024 UTC