Home  |  About  | Last |  Submit  |  Contact
AllQuests.com




Previous Question:  Login Sessions  PHPNext Question:  HELP  Technical Security Issues
Question help with strpos ( SitePoint Forums PHP )
Updated: 2008-11-23 03:25:03 (2)
help with strpos

Hi,
can someone please help with this.
This statement
if( strpos( $stats[1], '/' ) !== false )
$typeCount++;
will increment $typeCount when $stats[1]= 235197">J. Smith#1#0#0#0
or something similar. Rather it should not be incrementing $typeCount as there is no / character in that string.

Am I missing something?

Thanks for any help

Answers: help with strpos ( SitePoint Forums PHP )
help with strpos

Nothing is happening because you entire statement is evaluating as false therefore skipping the increment function.

strpost is returning false because it cannot find the '/'
then you are see if it does not equal false which is returns false because the result from the strpost is in fact false.

So basically when strpos has done its work you the if function looks like this:
PHP Code:

if(FALSE !== FALSE)

//increment
I hope you see what I mean you problem is here if( strpos( $stats[1], '/' ) !== false ) it should be: if( strpos( $stats[1], '/' ) === false ) I believe.

Edit:


Thanks Nigel, just skipped my mind (getting a little late) edited code

Opserty

help with strpos

Make sure you use === and not ==, because if it's matched in the first character of the string then you won't get the result you're after.

Nigel McNie

Previous Question:  Login Sessions  SitePoint Forums  PHPNext Question:  HELP  Web Hosting Talk  Technical Security Issues

- Source: help with strpos SitePoint Forums PHP
- Previous Question: Login Sessions SitePoint Forums PHP
- Next Question: HELP Web Hosting Talk Technical Security Issues