Welcome to WebmasterWorld Guest from 54.147.158.28

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Empty delimiter

     
12:08 am on Mar 2, 2012 (gmt 0)

Junior Member

joined:Feb 28, 2012
posts: 54
votes: 0


Getting an error:

PHP Warning: strpos() [<a href='function.strpos'>function.strpos</a>]: Empty delimiter in ../g1s.php on line 442


Section of code:
 $query = mysql_query('SELECT ip FROM games_banned_ip') or error_msg('Could not access database.');
while ($row = mysql_fetch_row($query))
{
$ip_check = strpos($player_ip, $row[0], 0);

if ($ip_check === 0) error_msg('Banned');
}


Line 442 is:
 $ip_check = strpos($player_ip, $row[0], 0); 


PHP Version: 5.2.9

Any advice appreciated.
Thank you.
1:02 am on Mar 2, 2012 (gmt 0)

Senior Member

WebmasterWorld Senior Member eelixduppy is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Nov 12, 2005
posts:5966
votes: 0


The warning message is telling you exactly what is wrong here..

$row[0]
is empty. Make sure you are getting a value there.
2:20 am on Mar 2, 2012 (gmt 0)

Junior Member

joined:Feb 28, 2012
posts: 54
votes: 0


Thank you for your reply.

For some reason, I must have deleted the 'blank' IP entry so the row was indeed empty.

Also, what might the following indicate please?

PHP Warning: Module 'timezonedb' already loaded in Unknown on line 0


Thank you
11:17 am on Mar 2, 2012 (gmt 0)

Senior Member

WebmasterWorld Senior Member 5+ Year Member

joined:Apr 30, 2007
posts:1394
votes: 0


When you do mysql queries to fetch rows make sure you have rows returned before doing the fetches. mysql_num_rows can return the number of rows of the result.

For the already loaded warning it looks like the module was attempted to be loaded dynamically (possibly via the php.ini file) but it's already compiled with the PHP version your run.
11:27 am on Mar 2, 2012 (gmt 0)

Junior Member

joined:Feb 28, 2012
posts: 54
votes: 0


I'm not going to pretend I know exactly what you mean in the first part of your reply, but will look into it, thank you.

Regarding the warning, am I correct in saying this can be commented out in the php.ini file to solve the problem ?
2:54 pm on Mar 2, 2012 (gmt 0)

Junior Member

joined:Feb 28, 2012
posts: 54
votes: 0


The warning message is telling you exactly what is wrong here..

$row[0] is empty. Make sure you are getting a value there.

Also, this is not fixed as I first thought. Could it be that an IP is not being successfully obtained by my getip() function ?
6:04 pm on Mar 2, 2012 (gmt 0)

Junior Member

joined:Feb 28, 2012
posts: 54
votes: 0


Adding an fully-formed IP address (0.0.0.0) to the empty database row did fix it. The reason it hadn't work was I'd added an incomplete IP (0.0.) initially.

Also, commenting out the duplicate 'timezonedb' in the php.ini file stopped the errors.

Thanks