Skip to content

Hebrew strings truncation #555

@shemi

Description

@shemi

When I try to pull data from our database I get shorter strings.
in this example, I use a stored procedure but I try to do select and the results the same

$serverName = "myServer";
$connectionOptions = array(
    "Database" => "$dbName",
    "UID" => "$dbUser",
    "PWD" => "$dbPassword"
);
//Establishes the connection
$conn = sqlsrv_connect($serverName, $connectionOptions);
if ($conn === false) {
    die(FormatErrors(sqlsrv_errors()));
}
//Select Query
$tsql = "exec AlumnusDataGet @id = 30000000";
//Executes the query
$getResults = sqlsrv_query($conn, $tsql);
//Error handling

if ($getResults == FALSE)
    die(FormatErrors(sqlsrv_errors()));
?>
    <h1> Results : </h1>
<?php
while ($row = sqlsrv_fetch_array($getResults, SQLSRV_FETCH_ASSOC)) {
    var_dump($row);
    echo("<br/>");
}
sqlsrv_free_stmt($getResults);
function FormatErrors($errors)
{
    /* Display errors. */
    echo "Error information: <br/>";

    foreach ($errors as $error) {
        echo "SQLSTATE: " . $error['SQLSTATE'] . "<br/>";
        echo "Code: " . $error['code'] . "<br/>";
        echo "Message: " . $error['message'] . "<br/>";
    }
}

The expected output is:

array 
  'TitleHeb' => 'גב''
  'LastNameHeb' => 'אלמן'
  'FirstNameHeb' => 'דנה'
  'TitleEng' => 'Ms.'
  'LastNameEng' => 'Elman'
 ...

The actual output:

array 
  'TitleHeb' => 'גב''
  'LastNameHeb' => 'אלמ'
  'FirstNameHeb' => 'דנ'
  'TitleEng' => 'Ms.'
  'LastNameEng' => 'Elman'
 ...

As you can see in the "LastNameHeb" and "FirstNameHeb" the last character is missing.

PHP Version: 7.1.3-3
Tested with both drivers (versions: 4., 5.)
OS: Ubuntu 16.04

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions