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:

Hello,

thank you for your suggestion, but as I reported it as a PHP bug, please
take it seriously and look for the reason that the strpos function do
not return the postiion of the string 'needle', even if the string
'needle' is contained in the string 'haystack'.


Previous Comments:
------------------------------------------------------------------------
[2010-07-04 17:44:58] premiso at gmail dot com

Christian, they have PHP Help forums and Joomla forums for you to use to
assist you 

with your issue.



Clearly this is NOT a PHP bug more over it is just you being an
incompetent 

"programmer". Please take this to a help forum, googling "php help
forum" will bring up 

plenty of places that will be more than happy to help you debug your
code.

------------------------------------------------------------------------
[2010-07-04 15:11:26] christian dot gnoth at arcor dot de

echo "j2wp_post = ".print_r($j2wp_post,1); // ADD THIS

echo "lnk_pos = ".$lnk_pos."\n";           // ADD THIS



$j2wp_wp_tb_prefix      = get_option('j2wp_wp_tb_prefix');

$j2wp_joomla_tb_prefix  = get_option('j2wp_joomla_tb_prefix');



echo "j2wp_wp_tb_prefix = $j2wp_wp_tb_prefix\n"; // ADD THIS

echo "j2wp_joomla_tb_prefix = $j2wp_joomla_tb_prefix\n"; // ADD THIS



the last two echo are not relevant for this problem, they are used for
mysql access.

the first two echos are too not relevant - I am doing already an echo to
the two variables I am passing to strpos!!!!!!!!!!!!!!!!!!!!!!!!!!!!



the $j2wp_post is an array with differnet fields for the wordpress posts
table. only the $j2wp_post['post_content'] field is intresting an this I
am extracting in the variable $post_lnk_string.

the variable $post_lnk_string I pass to the strpos function: To this
variable I am doing an echo. I have changed the script and printing now
the content of this variable with print_r as you suggest.



here is the source code:



  echo 'Post ID: ' . $j2wp_post['ID'] . ' link: ' .
print_r($post_lnk_string,true) . ' :' . print_r($strpos_ret,true) .
':<br />'; 

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

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

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

  echo 'Post ID: ' . $j2wp_post['ID'] . ' link: ' .
'href="index.php?option=com_content&view=article&id=9257:2009-fha-loan-limits&catid=52:fha&Itemid=97"'
. ' :' . $strpos_ret . ':<br />'; 

  //  urls with structure:
href="index.php?option=com_content&view=article&id=9257:2009-fha-loan-limits&catid=52:fha&Itemid=97"

  //  if ( $pos_article_id = strpos( $post_lnk_string, 'article&id=') )

  if ( !(strpos( $post_lnk_string, 'article&id=') === false) )





here is the output:



Post ID: 105 link: href="webcasts/llpa/llpa.html" ::

Post ID: 105 link: href="webcasts/llpa/llpa.html" ::

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

Post ID: 105 link: href="webcasts/llpa/llpa.html"

Post ID: 106 link:
href="component/search/ihda.html?ordering=&searchphrase=all" ::

Post ID: 106 link:
href="component/search/ihda.html?ordering=&searchphrase=all" ::

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

Post ID: 106 link:
href="component/search/ihda.html?ordering=&searchphrase=all"

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

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

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

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

------------------------------------------------------------------------
[2010-07-01 03:31:13] anon at anon dot com

This is hilarious.

------------------------------------------------------------------------
[2010-06-29 11:12:35] ras...@php.net

Would you please do what I asked 3 times already?  Make it possible for
us to 

reproduce your problem.  That means showing us your exact inputs.



eg.





function j2wp_change_single_url( $j2wp_post, $lnk_pos )

{

  global  $CON,

          $wpdb;



  echo "j2wp_post = ".print_r($j2wp_post,1); // ADD THIS

  echo "lnk_pos = ".$lnk_pos."\n";           // ADD THIS



  $j2wp_wp_tb_prefix      = get_option('j2wp_wp_tb_prefix');

  $j2wp_joomla_tb_prefix  = get_option('j2wp_joomla_tb_prefix');



  echo "j2wp_wp_tb_prefix = $j2wp_wp_tb_prefix\n"; // ADD THIS

  echo "j2wp_joomla_tb_prefix = $j2wp_joomla_tb_prefix\n"; // ADD THIS



  ...



  And do a View-Source for the results so you don't get tricked by
browser 

encodings.



Or better yet, make a little standalone case that includes this function
and 

pass the variables into it that is causing it to fail and put that up
somewhere.



I can assure you that strpos does not change based on any sort of
hosting 

environment issues.  Your problem is entirely in your code or in the
data you 

are passing into it.

------------------------------------------------------------------------
[2010-06-29 09:15:01] christian dot gnoth at arcor dot de

Hello,



that a standalone case is working or not is not the point here. Again I
do not doubt that the strpos function is working in a different
environment and test case. 

In the whole script it is working on different positions where I use
this strpos function!!!



But here in this working process it is not working !!!



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

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



In this two lines you can see that the variable $post_lnk_string is
passed to the strpos function. The echo after that shows the variable
content and the return of the strpos function. The standalone test case
is there !!! 



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"
::



shows the content of the variable with which it was passed to the strpos
function. Also it shows the return_value of the strpos function.



So, to tell it is not a PHP problem is not true - if the same script
with the same data is running in your environment without this problem -
then I think it is a problem of the environment which the webhoster
provides.

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


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