Edit report at http://bugs.php.net/bug.php?id=52198&edit=1

 ID:               52198
 Updated by:       ras...@php.net
 Reported by:      christian dot gnoth at arcor dot de
 Summary:          strpos not working correctly
 Status:           Bogus
 Type:             Bug
 Package:          Strings related
 Operating System: Linux
 PHP Version:      5.2.13

 New Comment:

Right, which is what I suggested on June 28, the day you 

reported the bug:



  My guess (since I can't decipher your messy code) is that 

  your POST data is probably getting parsed or filtered and

  the contents isn't what you think it is. Your & might

  actually be & so the strpos isn't going to match.



Next time, please listen to us to avoid wasting everyones' 

time.


Previous Comments:
------------------------------------------------------------------------
[2010-07-05 14:02:28] christian dot gnoth at arcor dot de

Ok, thank you for the hint. Indeed it is an & !!!

------------------------------------------------------------------------
[2010-07-05 04:45:26] me at whatever dot com

Christian,

once you do the echo on $post_lnk_string, use the View Source from the
browser.

Your links are not &, they are &



This is what I found in your SQL dump for the "link 107":



index.php?option=com_content&view=article&id=9257:2009-fha-loan-limits&catid=52:fha&Itemid=97



See... there is no "article&id=" there.

------------------------------------------------------------------------
[2010-07-05 04:10:16] ras...@php.net

The set of steps required to reproduce your problem is rather long. 
Hopefully 

you realize now why we aren't falling over ourselves reproducing your 

environment just to find your bug for you.



How about this:



Just before your strpos call, add this:



file_put_contents("/tmp/debug.txt",$post_lnk_string);



Then run this script:



<?php

$post_lnk_string = file_get_contents("/tmp/debug.txt");

var_dump(strpos($post_lnk_string, 'article&id='));





If that is still broken, you now have a small reproducing script.  If
you can't 

figure out your problem by looking at /tmp/debug.txt then zip or tar it
up and 

make it available to use somewhere.



Hint, I bet your & is actually &amp; or you have a non-printable char in
there, 

somewhere which you can check by doing: od -c /tmp/debug.txt

------------------------------------------------------------------------
[2010-07-04 23:08:46] paj...@php.net

Ok.



Using:



$post_lnk_string =
'href="index.php?option=com_content&view=article&id=9257:2009-fha-loan-limits&catid=52:fha&Itemid=97"';

$strpos_ret = strpos($post_lnk_string, 'article&id=');

var_dump($strpos_ret);



This script is exactly what you are doing. The output is:



int(40)



It works.



Your analyze about the memory are is wrong. Please check the
implementation if you like to verify it by yourself.

------------------------------------------------------------------------
[2010-07-04 22:40:03] christian dot gnoth at arcor dot de

Hello,

thank you for your qualified answer. But, please take a look at the
following lines:



$strpos_ret = strpos( $post_lnk_string, 'article&id=');

echo 'Post ID: ' . $j2wp_post['ID'] . ' link: ' . $post_lnk_string . '
:' . $strpos_ret . ':<br />'; 



and here is the output:



Post ID: 107 link:
href="index.php?option=com_content&view=article&id=9257:2009-fha-loan-limits&catid=52:fha&Itemid=97"
::



So the strpos function has no idea from were the input is comming.
Infact it is for the problem not intresting. Question is, from which
memory area it gets the input and what is there and how it is moved to
the strpos function. 

The variable which is passed to strpos contains the string
'article&id=', but this string is not found by the strpos function. 



So it is a bug in the PHP interpreter!!!



As you are the developer you should see that!!!

------------------------------------------------------------------------


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    http://bugs.php.net/bug.php?id=52198


-- 
Edit this bug report at http://bugs.php.net/bug.php?id=52198&edit=1

Reply via email to