Reputation: 323
In my query I have:
$search .= "and title REGEXP '[[:<:]]$q[[:>:]]' ";
Which produces the following error in the Apache error log:
PHP Parse error: syntax error, unexpected '[', expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING)
I tried putting {} around it, but that didn't work either.
Thank you.
Upvotes: 0
Views: 333
Reputation: 142518
Add braces: $search .= "and title REGEXP '[[:<:]]{$q}[[:>:]]'";
-- otherwise it thinks you are referencing the $q array.
PHP allows array lookups in strings, such as "... $q[...]
..." It also allows expresssions: "... {$a+$b} ..."
if you add the braces. Putting those together solves this problem.
Upvotes: 2