Need help, php error! T_variable error! Plz help!

Discussion in 'PHP' started by ElectroPayments, Mar 5, 2011.

  1. #1
    I'm having trouble with my search engine. The T_variable error is appearing.

    ERROR IS LINE 31. Whats wrong?

    27. {
    28.
    29.//constuct query
    30. $x++
    31. $construct .= "keywords LIKE '%$search_each%'";
    32. else
    33. $construct .="OR keywords LIKE '%$search_each%'";
    34.
    35. }

    Thanks!
     
    ElectroPayments, Mar 5, 2011 IP
  2. ssmm987

    ssmm987 Member

    Messages:
    180
    Likes Received:
    4
    Best Answers:
    3
    Trophy Points:
    43
    #2
    There is no if function?

    if(something)
    $construct .= "keywords LIKE '%$search_each%'";
    else
    $construct .="OR keywords LIKE '%$search_each%'"
     
    ssmm987, Mar 5, 2011 IP
  3. dgreenhouse

    dgreenhouse Peon

    Messages:
    24
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Also I noted you didn't terminate the line: $x++ with a semicolon.

    If that's not just a typo in your posting and is in the actual code,
    the PHP parser would see the line as: $x++ $construct .= "keywords LIKE '%$search_each%'";

    But what the error is actually saying is that the PHP parser was expecting
    an open parenthesis but found a variable - which would be the case if
    you didn't include an "if (condition)" clause as ssmm987 mentioned.
     
    dgreenhouse, Mar 5, 2011 IP
  4. ferostive

    ferostive Active Member

    Messages:
    162
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #4
    if (function)
    {


    //constuct query
    $x++
    $construct .= "keywords LIKE '%$search_each%'";
    } else {
    $construct .="OR keywords LIKE '%$search_each%'";

    }
     
    ferostive, Mar 5, 2011 IP
  5. eleetgeek

    eleetgeek Peon

    Messages:
    129
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    if (function)
    {
    //constuct query
    $x++;
    $construct .= "keywords LIKE '%$search_each%'";
    } else {
    $construct .="OR keywords LIKE '%$search_each%'";

    }
     
    eleetgeek, Mar 5, 2011 IP
  6. dgreenhouse

    dgreenhouse Peon

    Messages:
    24
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #6
    I must have been snoozing when mentioned the $x++ not being terminated point...

    If so, the parser would just fail - giving no error.

    Hope you fixed your issue.
     
    dgreenhouse, Mar 6, 2011 IP