PHP streams not reliable?

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

satchwinston
New php-forum User
New php-forum User
Posts: 2
Joined: Tue Apr 23, 2013 4:23 pm

PHP streams not reliable?

Postby satchwinston » Wed Apr 24, 2013 5:27 pm

I'm trying to read a stream from a PDO::PARAM_LOB retrieved from an Informix CLOB data type. It contains a large amount of xml. I simply use stream_get_contents($res).

It works most of the time but occasionally a few characters are missing on some of the longer ones. It screws up my xml parsing because attributes are misspelled and the syntax can get messed up. The data is coming from a Solaris server to Apache/PHP on a Linux server.

Is this a hardware problem or something is not right with PHP? Is there any way to fix this other than avoiding using a large object data type. It works fine when I use a LVARCHAR (no stream reading necessary) data type but I need a larger string.

I've tried reading the stream in chunks but the same thing happens. I have not tried reading it one character at a time.

johnj
php-forum Super User
php-forum Super User
Posts: 1805
Joined: Thu Mar 10, 2011 5:07 pm

Re: PHP streams not reliable?

Postby johnj » Wed Apr 24, 2013 8:03 pm

In that case, try using fopen() and then fread()

satchwinston
New php-forum User
New php-forum User
Posts: 2
Joined: Tue Apr 23, 2013 4:23 pm

Re: PHP streams not reliable?

Postby satchwinston » Thu Apr 25, 2013 5:21 pm

There is no file to open. I've used fread() but the same thing happens.

johnj
php-forum Super User
php-forum Super User
Posts: 1805
Joined: Thu Mar 10, 2011 5:07 pm

Re: PHP streams not reliable?

Postby johnj » Thu Apr 25, 2013 7:27 pm

Post the code if you can. Do you close the stream using fclose() after stream_get_contents()?


Return to “PHP coding => General”

Who is online

Users browsing this forum: No registered users and 2 guests