OK Found the answer, I had to put this :
$sge_prefix = (preg_match("/\?/", $cl['u']) ? "&" : "?");
$str[] = '<iframe> src="'.$cl['u'].$sge_prefix.'sgr=ACCESSDENIED" width="1" height="1" > </iframe>';
Right before the ?> at the end of /usr/local/www/sgerror.php, which for whatever reason didn't work earlier. This can be closed :)