Hi, I have the following PHP code
#Load the user preference types from the database
$sql="
SELECT `typeID`, `type`, `typeType`, `typeDefault`
FROM `usr_preftypes`
";
$sql_prefTypes=sqlQuery($sql,'sys:loadPrefTypes');
#Loop through the preference types and create the preference array and an array of preference data
$prefData=array();
$system['user']['prefs']=array();
while($prefType=mysql_fetch_assoc($sql_prefTypes)){
$prefData[$prefType['typeID']]=Array(
'type'=>$prefType['type'],
'typeType'=>$prefType['typeType']
);
#Check what type of setting it is
switch($prefType['typeType']){
case 'boolean':
$prefValue=($prefType['typeDefault']=='1');
break;
case 'integer':
$prefValue=intval($prefType['typeDefault']);
break;
default:
$prefValue=$prefType['typeDefault'];
}
$system['user']['prefs'][$prefType['type']]=$prefValue;
}
The code works perfectly but roughly once a week I get the following error
[14-May-2011 16:31:32] PHP Fatal error: Maximum execution time of 30 seconds exceeded in /var/www/.........../system.php on line 706.
Line 706 is "$prefValue=$prefType['typeDefault'];" after "default:". This entire file (862) lines consistently loads in a fraction of a second. I thought it's possible that something occasionally gets delayed such as one of the SQL queries further up the code but everytime I get this error it's on the exact same line. This file has around 10 queries so if that were the case I would expect the error to be in a random place.
Once I got the following error
[06-May-2011 05:04:00] PHP Fatal error: Invalid opcode 49/8/8. in /var/www/.........../system.php on line 707
That makes even less sense as line 707 is only a "}".
Is there anything wrong with my code that could cause this strange behaviour or could this be a bug in PHP?
PHP Version: 5.1.6
System: Redhat Linux 2.6.18-53.el5PAE #1
Apache Version: 2.2.17