Recent Topics

1 Dec 08, 2006 21:37    

In the "Search browser hits:" section of my Stats I get this message...

Notice: Undefined offset: 1 in /home/wow-factor/inc/MODEL/sessions/_hitlog.funcs.php on line 308

This doesn't show up on all pages of the Search Browser stats.

I get no other errors and the Stats themselves render fine.

Just curious and is there anything I can do about it.

2 Dec 10, 2006 16:07

That whole segment of code looks something like this :-

	$ref_params = explode( '&', substr( $ref, $pos_question+1 ) );
	foreach( $ref_params as $ref_param )
	{
		$param_parts = explode( '=', $ref_param );
		if( $param_parts[0] == 'q'
				or $param_parts[0] == 'as_q' 		// Google Advanced Search Query
				or $param_parts[0] == 'query'
				or $param_parts[0] == 'search'
				or $param_parts[0] == 'p'
				or $param_parts[0] == 'kw'
				or $param_parts[0] == 'qs'
				or $param_parts[0] == 'r'
				or $param_parts[0] == 'rdata'				// search.ke.voila.fr
				or $param_parts[0] == 'su'				// suche.web.de
			)
		{ // found "q" query parameter
			$q = urldecode($param_parts[1]);
			if( strpos( $q, 'Ã' ) !== false )		// fp> TODO: rewrite with in ASCII with a hex code
			{ // Probability that the string is UTF-8 encoded is very high, that'll do for now...
				//echo "[UTF-8 decoding]";
				$q = utf8_decode( $q );
			}
			$qwords = explode( ' ', $q );
			foreach( $qwords as $qw )
			{
				if( strlen( $qw ) > 30 ) $qw = substr( $qw, 0, 30 )."...";	// word too long, crop it
				$kwout .= $qw.' ';
			}
			return htmlentities($kwout);

What would "appear" to be happening is that one of these is occurring with either an empty value or no "="

		if( $param_parts[0] == 'q'
				or $param_parts[0] == 'as_q'
				or $param_parts[0] == 'query'
				or $param_parts[0] == 'search'
				or $param_parts[0] == 'p'
				or $param_parts[0] == 'kw'
				or $param_parts[0] == 'qs'
				or $param_parts[0] == 'r'
				or $param_parts[0] == 'rdata'	
				or $param_parts[0] == 'su'

You can probably cure it by changing the code to :-

if( !empty( $param_parts[1] )
{
			$q = urldecode($param_parts[1]);
			if( strpos( $q, 'Ã' ) !== false )		// fp> TODO: rewrite with in ASCII with a hex code
			{ // Probability that the string is UTF-8 encoded is very high, that'll do for now...
				//echo "[UTF-8 decoding]";
				$q = utf8_decode( $q );
			}
			$qwords = explode( ' ', $q );
			foreach( $qwords as $qw )
			{
				if( strlen( $qw ) > 30 ) $qw = substr( $qw, 0, 30 )."...";	// word too long, crop it
				$kwout .= $qw.' ';
			}
			return htmlentities($kwout);
		}
}

but it'd be interesting to see the hits that have caused the error.

please note : the cure is entirely without testing and could cause your blog to chew all of your database tables and spit them out as tiny fragments of their former self ....... either that or it'll just show errors :|

¥

3 Dec 10, 2006 22:32

Thanks, I'll have a fiddle with that. If I stuff it up I'll no doubt be in touch :)


Form is loading...