homepage Welcome to WebmasterWorld Guest from 54.205.207.53
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Empty delimiter
Seedy



 
Msg#: 4423903 posted 12:08 am on Mar 2, 2012 (gmt 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.

 

eelixduppy

WebmasterWorld Senior Member eelixduppy us a WebmasterWorld Top Contributor of All Time 5+ Year Member



 
Msg#: 4423903 posted 1:02 am on Mar 2, 2012 (gmt 0)

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

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



 
Msg#: 4423903 posted 2:20 am on Mar 2, 2012 (gmt 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

enigma1

WebmasterWorld Senior Member 5+ Year Member



 
Msg#: 4423903 posted 11:17 am on Mar 2, 2012 (gmt 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.

Seedy



 
Msg#: 4423903 posted 11:27 am on Mar 2, 2012 (gmt 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 ?

Seedy



 
Msg#: 4423903 posted 2:54 pm on Mar 2, 2012 (gmt 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 ?

Seedy



 
Msg#: 4423903 posted 6:04 pm on Mar 2, 2012 (gmt 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

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved