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??? Link to comment https://forums.phpfreaks.com/topic/23188-using-regexp-with-select-staements-matching-whole-words-within-a-field/ 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. Link to comment https://forums.phpfreaks.com/topic/23188-using-regexp-with-select-staements-matching-whole-words-within-a-field/#findComment-105108 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??? Link to comment https://forums.phpfreaks.com/topic/23188-using-regexp-with-select-staements-matching-whole-words-within-a-field/#findComment-105183 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]. Link to comment https://forums.phpfreaks.com/topic/23188-using-regexp-with-select-staements-matching-whole-words-within-a-field/#findComment-105201 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.