jmichael68 Posted October 6, 2006 Share Posted October 6, 2006 Here is the code that I have problems with...$query22 = "SELECT '$text' from dpl WHERE $field REGEXP '[[:<:]]$text[[:>:]]'";I'm looking to match whole words that are in variable $text. This works when you put '[[:<:]]JOHN[[:>:]]', is there a way to use this statement with a variable??? Quote Link to comment Share on other sites More sharing options...
effigy Posted October 6, 2006 Share Posted October 6, 2006 This should work. Make sure $text and $field contain what you expect, and that the database connection and selection is working properly. Quote Link to comment Share on other sites More sharing options...
jmichael68 Posted October 6, 2006 Author Share Posted October 6, 2006 if I use this:$query22 = "SELECT * from dpl WHERE Name REGEXP '[[:<:]]$name[[:>:]]'";I get this error message:Parse error: parse error, unexpected '[', expecting T_STRING or T_VARIABLE or T_NUM_STRING but my array is returning this.... SELECT * from dpl WHERE Name REGEXP '[[:<:]]RAY[[:>:]]'SELECT * from dpl WHERE Name REGEXP '[[:<:]]VLADIMIR[[:>:]]'SELECT * from dpl WHERE Name REGEXP '[[:<:]]MOHAMMED[[:>:]]'when I hard code "RAY" in the statement like this...SELECT * from dpl WHERE Name REGEXP '[[:<:]]RAY[[:>:]]'It works??? Quote Link to comment Share on other sites More sharing options...
effigy Posted October 6, 2006 Share Posted October 6, 2006 Ah...[tt] $name[[/tt] is being seen as an array, change it to[tt] $name\[[/tt]. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.