views:

3763

answers:

3

I have an import-from-excel script as part of a CMS that previously ran without issue.

My shared-hosting provider has recently upgraded their infrastructure, including PHP from 5.1 to 5.2.6, and the script now returns "Uninitialized string offset: -XXX in /path/scriptname.php on line 27" (XXX being a decreasing number from 512 and /path/scriptname.php of course being the full path to script in question).

It returns this error for every line of the excel file. Line 27 is just a return from within a function that is the first point at which the imported data is being processed:

function GetInt4d($data, $pos) {
        return ord($data[$pos]) | (ord($data[$pos+1]) << 8) | (ord($data[$pos+2]) << 16) | (ord($data[$pos+3]) << 24); 
}

It finally implodes with a "Fatal error: Allowed memory size of 47185920 bytes exhausted (tried to allocate 71 bytes) in /path/scriptname.php on line 133".

There's nothing useful in Apache error logs. I am stumped. Anyone have any ideas of at least where to look? Even knowing if it's likely to be something within my script or something to do with upgrade would be useful. I had another issue with a different site on same provider that (after upgrade) couldn't write sessions to tmp directory (since resolved), but am pretty sure it's not that (?).

EDIT: As it turned out that the answer was to do with the version of the parser being incompatible in some way with PHP 5.2.6, I thought it might be of use to someone that the parser in question is Spreadsheet Excel Reader .

+1  A: 

Uninitialized string offset:

... means that $data is not an array.

Till
+1  A: 

Thanks for the input, the situation has 'resolved itself' via me finding a more recent version of the parsing library I was using. My guess is the issue was something to do with the difference between php versions, though I'm unsure exactly what. Fixed but frustrating.

EDIT: I'm going to accept Till's answer purely in the interests of closing the question. Thx again for input.

da5id
+1  A: 

Solved here: http://www.phpbuilder.com/board/archive/index.php/t-10328608.html