homepage Welcome to WebmasterWorld Guest from 50.19.169.37
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Visit PubCon.com
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:4423905
 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




msg:4423914
 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:4423940
 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




msg:4424088
 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:4424090
 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:4424141
 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:4424221
 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