Script error under PHP 4.3.3

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Andrew Banks

    Script error under PHP 4.3.3

    Could anyone identify why the following script is giving me various errors
    under php 4.3.3. It worked fine on previous versions.

    function cut_string($str ing,$wordnum,$t rail)
    {
    $string_arr=exp lode(" ",$string);
    for($i=0;$i<$wo rdnum;$i++)
    {
    $re_string.= " ".$string_a rr[$i];
    }
    $str= $re_string.$tra il;
    print $str;
    }

    Thanks in advance


  • William Maddler

    #2
    Re: Script error under PHP 4.3.3

    Andrew Banks wrote:
    [color=blue]
    > Could anyone identify why the following script is giving me various errors
    > under php 4.3.3. It worked fine on previous versions.[/color]

    maybe telling wich errors comes out would help...

    --
    WM

    Comment

    • Andy Hassall

      #3
      Re: Script error under PHP 4.3.3

      On Mon, 06 Oct 2003 09:05:13 GMT, "Andrew Banks"
      <banksy@nospamb lueyonder.co.uk > wrote:
      [color=blue]
      >Could anyone identify why the following script is giving me various errors
      >under php 4.3.3. It worked fine on previous versions.[/color]

      Post the 'various errors'.
      [color=blue]
      >function cut_string($str ing,$wordnum,$t rail)
      > {
      >$string_arr=ex plode(" ",$string);
      >for($i=0;$i<$w ordnum;$i++)
      >{
      >$re_string.= " ".$string_a rr[$i];
      >}
      >$str= $re_string.$tra il;
      >print $str;
      >}[/color]

      Compiles fine here under 4.3.3. If it's giving errors at runtime, post
      examples of data that cause them, and the errors themselves.

      --
      Andy Hassall (andy@andyh.co. uk) icq(5747695) (http://www.andyh.co.uk)
      Space: disk usage analysis tool (http://www.andyhsoftware.co.uk/space)

      Comment

      • Pedro

        #4
        Re: Script error under PHP 4.3.3

        Andrew Banks wrote:[color=blue]
        > Could anyone identify why the following script is giving me various errors
        > under php 4.3.3. It worked fine on previous versions.
        >
        > function cut_string($str ing,$wordnum,$t rail)
        > {
        > $string_arr=exp lode(" ",$string);[/color]

        ### check wordnum against actual number of words in string_arr
        if ($wordnum > count($string_a rr)) $wordnum = count($string_a rr);

        ### and please, please, please initialize re_string
        $re_string = '';
        [color=blue]
        > for($i=0;$i<$wo rdnum;$i++)
        > {
        > $re_string.= " ".$string_a rr[$i];
        > }
        > $str= $re_string.$tra il;
        > print $str;
        > }
        >
        > Thanks in advance[/color]


        If you'd tell us what the errors are it might be easier to tell you why
        they show up.

        --
        I have a spam filter working.
        To mail me include "urkxvq" (with or without the quotes)
        in the subject line, or your mail will be ruthlessly discarded.

        Comment

        • Paulus Magnus

          #5
          Re: Script error under PHP 4.3.3


          "Andrew Banks" <banksy@nospamb lueyonder.co.uk > wrote in message
          news:dfagb.1030 2$8t1.86775966@ news-text.cableinet. net...[color=blue]
          > Could anyone identify why the following script is giving me various errors
          > under php 4.3.3. It worked fine on previous versions.
          >
          > function cut_string($str ing,$wordnum,$t rail)
          > {
          > $string_arr=exp lode(" ",$string);
          > for($i=0;$i<$wo rdnum;$i++)
          > {
          > $re_string.= " ".$string_a rr[$i];
          > }
          > $str= $re_string.$tra il;
          > print $str;
          > }[/color]

          I imagine that $wordnum > count ($string_arr) for the set of parameters
          you're passing to this function. You need to modify your routine to count up
          to $wordnum only if count ($string_arr) >= $wordnum.

          Paulus


          Comment

          Working...