php string parsing

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

    #1

    php string parsing

    I am trying to build a where clause for mysql based on different form
    inputs but php seems to have a problem with the following:

    $whrClause = "WHERE keywords LIKE '%$keywords%'"

    I thought with the double quotes that the single-quote and percent
    signs would remain unchanged and the variable $keywords would be
    expanded to its value, but I guess I am wrong because i get a parsing
    error... Any help for a php newbie?
  • Jochen Daum

    #2
    Re: php string parsing

    Hi,

    On 17 Mar 2004 19:38:56 -0800, keithwheeler@co x.net (keith) wrote:
    [color=blue]
    >I am trying to build a where clause for mysql based on different form
    >inputs but php seems to have a problem with the following:
    >
    >$whrClause = "WHERE keywords LIKE '%$keywords%'"
    >[/color]

    semicolon?

    HTH, Jochen
    [color=blue]
    >I thought with the double quotes that the single-quote and percent
    >signs would remain unchanged and the variable $keywords would be
    >expanded to its value, but I guess I am wrong because i get a parsing
    >error... Any help for a php newbie?[/color]

    --
    Jochen Daum - Cabletalk Group Ltd.
    PHP DB Edit Toolkit -- PHP scripts for building
    database editing interfaces.
    http://sourceforge.net/projects/phpdbedittk/

    Comment

    • IndyTim

      #3
      Re: php string parsing

      Jochen Daum wrote:
      [color=blue]
      > Hi,
      >
      > On 17 Mar 2004 19:38:56 -0800, keithwheeler@co x.net (keith) wrote:
      >
      >[color=green]
      >>I am trying to build a where clause for mysql based on different form
      >>inputs but php seems to have a problem with the following:
      >>
      >>$whrClause = "WHERE keywords LIKE '%$keywords%'"
      >>[/color]
      >
      >
      > semicolon?
      >
      > HTH, Jochen
      >
      >[color=green]
      >>I thought with the double quotes that the single-quote and percent
      >>signs would remain unchanged and the variable $keywords would be
      >>expanded to its value, but I guess I am wrong because i get a parsing
      >>error... Any help for a php newbie?[/color]
      >
      >[/color]
      Try:

      $whrClause = "WHERE keywords LIKE %'$keywords'%"

      You want to pass the literal of $keywords, not the literal of %$keywords%.

      IndyTim[color=blue][color=green]
      >>[/color][/color]

      Comment

      • keith

        #4
        Re: php string parsing

        Jochen Daum <jochen.daum@ca bletalk.co.nz> wrote in message news:<sb7i50d4p ulpm7skc9t4dnet ec200ifdha@4ax. com>...[color=blue]
        > Hi,
        >
        > On 17 Mar 2004 19:38:56 -0800, keithwheeler@co x.net (keith) wrote:
        >[color=green]
        > >I am trying to build a where clause for mysql based on different form
        > >inputs but php seems to have a problem with the following:
        > >
        > >$whrClause = "WHERE keywords LIKE '%$keywords%'"
        > >[/color]
        >
        > semicolon?
        >
        > HTH, Jochen
        >[color=green]
        > >I thought with the double quotes that the single-quote and percent
        > >signs would remain unchanged and the variable $keywords would be
        > >expanded to its value, but I guess I am wrong because i get a parsing
        > >error... Any help for a php newbie?[/color][/color]


        YEP, lol - the switch from vbscript to php is killing me. Thanks for the help.

        Comment

        Working...