problem writing text search function

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Matthew Robinson

    problem writing text search function

    i get "Parse error: parse error in /home/houseproudlancs _co_uk/search.php
    on line 65" when i open the page, line 65 would be the line that starts
    with if (textsearch

    $search_for = "is";
    $the_items_desc ription = "this is where the description would go";
    if (textsearch($it em_category) == true {
    echo ("correct");
    } else {
    echo ("incorrect" );
    }


    function textsearch($the _items_descript ion)
    {

    $pos = strpos($the_ite ms_description, $search_for);

    if ($pos === false) {
    textsearch = false;
    } else {
    textsearch = true;
    }
  • Tom Thackrey

    #2
    Re: problem writing text search function


    On 9-Jan-2004, Matthew Robinson <mattyrobinson6 9@hotmail.com> wrote:
    [color=blue]
    > i get "Parse error: parse error in /home/houseproudlancs _co_uk/search.php
    > on line 65" when i open the page, line 65 would be the line that starts
    > with if (textsearch
    >
    > $search_for = "is";
    > $the_items_desc ription = "this is where the description would go";
    > if (textsearch($it em_category) == true {
    > echo ("correct");
    > } else {
    > echo ("incorrect" );
    > }[/color]

    You need another ) on the if

    --
    Tom Thackrey

    tom (at) creative (dash) light (dot) com
    do NOT send email to jamesbutler@wil lglen.net (it's reserved for spammers)

    Comment

    • Boyd

      #3
      Re: problem writing text search function

      In article <pan.2004.01.09 .20.48.56.40533 2@hotmail.com>,
      mattyrobinson69 @hotmail.com says...[color=blue]
      > i get "Parse error: parse error in /home/houseproudlancs _co_uk/search.php
      > on line 65" when i open the page, line 65 would be the line that starts
      > with if (textsearch
      >
      > $search_for = "is";
      > $the_items_desc ription = "this is where the description would go";
      > if (textsearch($it em_category) == true {[/color]


      2 open brackets and only on closed.


      --
      *************** *************** ********
      The Eldritch Dark:
      Dedicated to Clark Ashton Smith

      Comment

      • Matthew Robinson

        #4
        Re: problem writing text search function

        that didn't help unfortunately (please forgive me for the VB coder type
        error - im used to VB wiping my bum for me) any other idea's?

        Comment

        • Tom Thackrey

          #5
          Re: problem writing text search function


          On 9-Jan-2004, Matthew Robinson <mattyrobinson6 9@hotmail.com> wrote:
          [color=blue]
          > that didn't help unfortunately (please forgive me for the VB coder type
          > error - im used to VB wiping my bum for me) any other idea's?[/color]

          consider quoting whatever the hell you are referring to and what you did and
          what the new problem is.



          --
          Tom Thackrey

          tom (at) creative (dash) light (dot) com
          do NOT send email to jamesbutler@wil lglen.net (it's reserved for spammers)

          Comment

          • Matthew Robinson

            #6
            Re: problem writing text search function

            the original problem was i get "Parse error: parse error in
            /home/houseproudlancs _co_uk/search.php on line 65" when i open the page,
            line 65 would be the line that starts with if (textsearch

            the help suggested was to put the missing ) on the if statement, i have
            done this (as below) and it didn't help

            $search_for = "is";
            $the_items_desc ription = "this is where the description would go";
            if (textsearch($it em_category)) == true {
            echo ("correct");
            } else {
            echo ("incorrect" );
            }


            function textsearch($the _items_descript ion)
            {

            $pos = strpos($the_ite ms_description, $search_for);

            if ($pos === false) {
            textsearch = false;
            } else {
            textsearch = true;
            }

            Comment

            • Pedro Graca

              #7
              Re: problem writing text search function

              Matthew Robinson wrote:[color=blue]
              > that didn't help unfortunately (please forgive me for the VB coder type
              > error - im used to VB wiping my bum for me) any other idea's?[/color]
              [color=blue][color=green][color=darkred]
              >>> if (textsearch($it em_category) == true {[/color][/color][/color]
              _______^_______ ___^___________ ___^___________ _______________ ???????

              where did you put the missing ")"?
              --
              --= my mail box only accepts =--
              --= Content-Type: text/plain =--
              --= Size below 10001 bytes =--

              Comment

              • Matthew Robinson

                #8
                Re: problem writing text search function

                On Fri, 09 Jan 2004 22:55:12 +0000, Pedro Graca wrote:
                [color=blue]
                > Matthew Robinson wrote:[color=green]
                >> that didn't help unfortunately (please forgive me for the VB coder type
                >> error - im used to VB wiping my bum for me) any other idea's?[/color]
                >[color=green][color=darkred]
                >>>> if (textsearch($it em_category) == true {[/color][/color]
                > _______^_______ ___^___________ ___^___________ _______________ ???????
                >
                > where did you put the missing ")"?[/color]


                it was
                if (textsearch($it em_category) == true {

                i replaced this with
                if (textsearch($it em_category)) == true {

                Comment

                • Pedro Graca

                  #9
                  Re: problem writing text search function

                  Matthew Robinson wrote:[color=blue]
                  > it was
                  > if (textsearch($it em_category) == true {
                  >
                  > i replaced this with
                  > if (textsearch($it em_category)) == true {[/color]

                  And as you've seen that is still wrong.
                  Try again.

                  Hint: check the if() syntax
                  PHP is a popular general-purpose scripting language that powers everything from your blog to the most popular websites in the world.

                  --
                  --= my mail box only accepts =--
                  --= Content-Type: text/plain =--
                  --= Size below 10001 bytes =--

                  Comment

                  • Tom Thackrey

                    #10
                    Re: problem writing text search function


                    On 9-Jan-2004, Matthew Robinson <mattyrobinson6 9@hotmail.com> wrote:
                    [color=blue]
                    > if (textsearch($it em_category)) == true {[/color]

                    You put the missing ) in the wrong place it should be:

                    if (textsearch($it em_category) == true) {


                    --
                    Tom Thackrey

                    tom (at) creative (dash) light (dot) com
                    do NOT send email to jamesbutler@wil lglen.net (it's reserved for spammers)

                    Comment

                    • Chung Leong

                      #11
                      Re: problem writing text search function

                      PHP use the keyword "return" for returning a value from a function. And
                      variables are not global by default. Hence:

                      function textsearch($the _items_descript ion)
                      {
                      global $search_for;

                      $pos = strpos($the_ite ms_description, $search_for);

                      if ($pos === false) {
                      return false;
                      } else {
                      return true;
                      }
                      }

                      or shorter:

                      function textsearch($the _items_descript ion)
                      {
                      global $search_for;

                      $pos = strpos($the_ite ms_description, $search_for);

                      return ($pos !== false);
                      }

                      or shorter still:

                      strstr($the_ite ms_description, $search_for);

                      Uzytkownik "Matthew Robinson" <mattyrobinson6 9@hotmail.com> napisal w
                      wiadomosci news:pan.2004.0 1.09.20.48.56.4 05332@hotmail.c om...[color=blue]
                      > i get "Parse error: parse error in /home/houseproudlancs _co_uk/search.php
                      > on line 65" when i open the page, line 65 would be the line that starts
                      > with if (textsearch
                      >
                      > $search_for = "is";
                      > $the_items_desc ription = "this is where the description would go";
                      > if (textsearch($it em_category) == true {
                      > echo ("correct");
                      > } else {
                      > echo ("incorrect" );
                      > }
                      >
                      >
                      > function textsearch($the _items_descript ion)
                      > {
                      >
                      > $pos = strpos($the_ite ms_description, $search_for);
                      >
                      > if ($pos === false) {
                      > textsearch = false;
                      > } else {
                      > textsearch = true;
                      > }[/color]


                      Comment

                      • Geoff Berrow

                        #12
                        Re: problem writing text search function

                        I noticed that Message-ID: <pan.2004.01.09 .22.58.44.43058 1@hotmail.com>
                        from Matthew Robinson contained the following:
                        [color=blue]
                        >$search_for = "is";
                        >$the_items_des cription = "this is where the description would go";
                        >if (textsearch($it em_category)) == true {
                        >echo ("correct");
                        >} else {
                        >echo ("incorrect" );
                        >}[/color]

                        well you know it should be

                        if (textsearch($it em_category) == true){...}

                        now, but for this test did you not perhaps mean to write

                        $item_category = "this is where the description would go";
                        if (textsearch($it em_category == true)) {...}
                        --
                        Geoff Berrow (put thecat out to email)
                        It's only Usenet, no one dies.
                        My opinions, not the committee's, mine.
                        Simple RFDs http://www.ckdog.co.uk/rfdmaker/

                        Comment

                        Working...