Edit report at http://bugs.php.net/bug.php?id=52198&edit=1
ID: 52198 Comment by: christian dot gnoth at arcor dot de 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: Ok, thank you for the hint. Indeed it is an & !!! Previous Comments: ------------------------------------------------------------------------ [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 & 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!!! ------------------------------------------------------------------------ [2010-07-04 21:42:50] paj...@php.net Please understand that strpos has absolutely no idea where the strings you pass it come from (ich meine es: echt keine Ahnung). What is so hard to understand to actually do what Rasmus has been asking for a week now? Provide a script like the one I wrote in my previous comment. If you can't reproduce it using such a simple script, then something is wrong somewhere else in your code. If you keep need support, I would suggest to go to either the php-general mailing or to whatever is the support channel for Wordpress. But bugs.php.net is not such channel. Thanks for your understanding. ------------------------------------------------------------------------ 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