Found the offending code:
From gallery code for random and latest:
global $sourcedir, $user_info, $ID_MEMBER, $context, $txt, $galurl, $galurl2, $scripturl, $settings, $db_prefix;
require_once($sourcedir . '/Subs-MGallery.php');
loadMGal_Settings();
if(loadlanguage('MGallery') == false)
loadLanguage('MGallery', 'english');
$items = getMediaItems(0, 5, 'RAND()');
echo '
<center><table>
<br />
<div style="font-size=110%; font-weight: bold; line-height: 1.8em;" style="text-align:center;"></div><div class="smalltext" style="text-align: center; line-height: 1.4em;"><br /></div>
';
foreach($items as $item)
echo '
<td>
<div class="smalltext" style=" line-height: 1.4em; border: 0px #000000 solid; padding: 5px;">
<a href="',$galurl,'sa=item&id=',$item['id'],'">',$item['title'],'</a><br />
<a href="',$galurl,'sa=item&id=',$item['id'],'"><img alt="" src="',$galurl,'sa=media&id=',$item['id'],';thumb" alt="" /></a><br />
',$txt['mgallery_views'],' : ',$item['views'],'<br />
',$txt['mgallery_posted_by'],' : <a href="',$scripturl,'?action=profile;u=',$item['member_id'],'">',$item['member_name'],'</a><br />
',$txt['mgallery_in_album'],' : <a href="',$galurl,'sa=viewalbum&id=',$item['id_album'],'">',$item['album_name'],'</a>
',$item['is_new'] ? '<br /><img alt="" src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/new.gif" border="0" />' : '','
</div>
</td>';
echo '
</tr>
</table></center>';
How can I fix it so the errors stop happening?