I’ve just moved my script to new server running php7 (from server running php5.3) and I’m getting following warming:
Warning: Illegal offset type in C:\inetpub\wwwroot\script.php on line 23
Warning refers to those lines from the script below:
[php]
$timeStamp[$row->cusLastEdited] = $row->cusTimestamp;
$timeStamp[$row->locLastEdited] = $row->locTimestamp;
$timeStamp[$row->jobAllLastEdited] = $row->jobAllTimestamp;
[/php]
And the array ends up to be empty.
Any help would be greatly appreciated.
[php]
$query = sqlsrv_query($link,"
SELECT $valLocation, $valContact, $valCustomers, LOC.LocationID, CUS.PrivateNotes, CUS.CustomerID, CUS.LastEdited AS cusLastEdited, LOC.LastEdited AS locLastEdited, JALL.LastEdited AS jobAllLastEdited, JACT.isActiveJobStartDate, JACT.StartTime, JACT.ArriveWindow, JCOM.isCompleteJobStartDate, JFIRSTCOM.isFirstServiceDate,
CONVERT ( varchar , CUS.LastEdited , 112 ) + CONVERT ( varchar , CUS.LastEdited , 108 ) AS cusTimestamp,
CONVERT ( varchar , LOC.LastEdited , 112 ) + CONVERT ( varchar , LOC.LastEdited , 108 ) AS locTimestamp,
CONVERT ( varchar , CUS.BirthDate , 112 ) + ‘T’ + CONVERT ( varchar , CUS.BirthDate , 108 ) AS birthTimestamp,
JALL.jobAllTimestamp
FROM tblCustomers CUS
// the query goes on…
");
errorCheck($query);
while ($row = sqlsrv_fetch_object($query)) {
$CustomerID = $row->CustomerID;
$ExtraId = $row->Extra26;
// reset the array
$timeStamp = array();
// Select the most recent LastEdited value
$timeStamp[$row->cusLastEdited] = $row->cusTimestamp;
$timeStamp[$row->locLastEdited] = $row->locTimestamp;
$timeStamp[$row->jobAllLastEdited] = $row->jobAllTimestamp;
$maxTimeStamp = max($timeStamp);
$timeStamp = array_flip($timeStamp);
$maxLastEdited = $timeStamp[$maxTimeStamp];
}
[/php]