String missing characters(from php database)

Asked

Viewed 58 times

0

What is happening here is that a string (varchar), coming from a database query, is missing characters when I go to php , php read until a certain part later stops. When I do a query Using SQL Server Management Studio, the string is complete but when I go to php, php only reads to a certain part.

SELECT Exemplo
from tableExemplo
where tableExemplo.Codigo = X 

By doing this the SQL Server Management Studio string will present the value : "VARIOS: INSURER CHARGED 06/01/2020 AND 22/01/2020 ALL NFS 107909/1,111983/1,112375/1,112756/1,112793/1,112988/1,113117/1,113482/1,113580/1,114036/1,114039/1,114606/1,115956/1,116809/1,119221/1,120149/1121338/1,122063/1,122288/1,12454/1,125835/1,134878/1,1480/1,142282/1,145483/1,150156/1,152001/1,154225/1,154681/1,155069/1,161504/1,161690/1,"

In php the code is like this

function ExemploString($codigo){

return $this->db->query(" SELECT Exemplo
from tableExemplo
where tableExemplo.Codigo = $codigo";
}

$dataTeste = ExemploString(X);

echo"<pre>";
print_r($dataTeste);
echo"</pre>";

When executing the above code echo and print_r will display the result:

Array
(
    [0] => stdClass Object
        (

           [Exemplo] => VARIOS: COBRADO DA SEGURADORA EM 06/01/2020 E EM 22/01/2020 TODAS AS NFS 107909/1,111983/1,112375/1,112756/1,112793/1,112988/1,113117/1,113482/1,113580/1,114036/1,114039/1,114606

        )

)

He’s just printing out some of the contents. already tried utf8_decode, utf8_encode, removes line break in select but still printing incomplete.

  • Can you put the connection string in the question? Some drivers limit the amount of characters sent. For example Freetds limits to 255 characters, and to get the whole text you need to cast a column for text: SELECT CAST(Exemplo as TEXT) FROM tableExemplo where...

  • In your print_r($dbData), it should not be print_r($dataTeste) ?

  • Corrected, thank you

1 answer

0

The print_r function truncates a string that has more than 1024 characters. The solution is to pass TRUE to the second function parameter print_r

echo '<pre>' . print_r ($bigArray, TRUE) . '</pre>';

Browser other questions tagged

You are not signed in. Login or sign up in order to post.