Categories > TinyButStrong general >

bug or?

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: ant
Date: 2004-02-22
Time: 20:13

bug or?

Warning: strpos(): Offset not contained in string. in d:\www-dev\turists\inc\tbs_class.php on line 239
By: Skrol29
Date: 2004-02-23
Time: 09:57

Re: bug or?

Hi,

Thts's the line where TBS search for a TBS tag. But I need more details to understand why this warnig happens.

Could you send me a piece of code+template to reproduce this warning?
By: ant
Date: 2004-02-24
Time: 20:40

Re: bug or?

hello again.
Error happens only when i use nv bar and there is only one page in results.
i using php and html code from your examples.
By: ant
Date: 2004-02-24
Time: 20:46

Re: bug or?

and when i remove html piece with nav bar (but php stay), then there no error.
By: Skrol29
Date: 2004-02-25
Time: 11:04

Re: bug or?

I can't reproduce your bug with the example :(
By: bunak
Date: 2004-06-01
Time: 12:41

Re: bug or?

I found the same problem in version 1.96. When you click on last page (number or >| ) You get this message
"Warning: strpos(): Offset not contained in string. in c:\apache\htdocs\indesign\tbs\tbs_class.php on line 268
" but You get correct data.
By: RwD
Date: 2004-06-01
Time: 16:18

Re: bug or?

Can you show the template, the PHP code and an extract of the database??
By: Skrol29
Date: 2004-06-02
Time: 02:38

Re: bug or?

Hi,

I maybe know what is the bug.
But I'm not sure because I've never be able to reproduce it.
Those who have this bug: could you please test/replace the fallowing function and see if it fixes the bug?
Thanks,

function tbs_Locator_FindTbs(&$Txt,$Name,$Pos,$AcceptSub) {

  $PosEnd = False ;
  $PosMax = strlen($Txt) -1;

  do {

    //Search for the opening char
    if ($Pos>$PosMax) return False;
    $PosOpen = strpos($Txt,$GLOBALS['tbs_ChrOpen'],$Pos) ;

    //If found => the next char are analyzed
    if ($PosOpen===False) {
      return False;
    } else {
      $Pos = $PosOpen + 1;
      //Look if what is next the begin char is the name of the locator
      if (strcasecmp(substr($Txt,$PosOpen+1,strlen($Name)),$Name)===0) {

        $Loc = new clsTbsLocator ;

        //Then we check if what is next the name of the merge is an expected char
        $ReadPrm = False ;
        $PosX = $PosOpen + 1 + strlen($Name) ;
        $x = $Txt[$PosX] ;

        if ($x===$GLOBALS['tbs_ChrClose']) {
          $PosEnd = $PosX ;
        } elseif ($AcceptSub and ($x==='.')) {
          $Loc->SubName = '' ; //it is no longer the false value
          $ReadPrm = True ;
          $PosX++ ;
        } elseif (strpos(';',$x)!==False) {
          $ReadPrm = True ;
          $PosX++ ;
        }

        if ($ReadPrm) {
          //Read the Parameters
          tbs_Locator_ReadPrm($Txt,$PosX,';','= ','\'','([{',')]}',$GLOBALS['tbs_ChrClose'],0,$Loc,$PosEnd) ;
          if (isset($Loc->PrmLst['comm'])) { //Enlarge the limits to the comentary bounds.
            tbs_Locator_EnlargeToStr($Txt, $PosOpen, $PosEnd, '<!--' ,'-->') ;
          }
        }

      }
    }

  } while ($PosEnd===False) ;

  $Loc->PosBeg = $PosOpen ;
  $Loc->PosEnd = $PosEnd ;
  if ($Loc->SubName===False) {
    $Loc->FullName = $Name ;
  } else {
    $Loc->FullName = $Name.'.'.$Loc->SubName ;
  }
 
  return $Loc ;

}
By: bunak
Date: 2004-06-02
Time: 14:49

Re: bug or?

It WORKS! Many thanks Skrol29. I solve this problem yesterday late night similary like You, but I still haven't time to describe it. But Your solution is better. Once again thanks
Bunak
By: bunak
Date: 2004-06-02
Time: 14:51

Re: bug or?

it happened when offset in  strpos() is set on position after Txt lenght