Re: [PHP] str_replace on words with an array

2006-11-04 Thread Dotan Cohen
On 03/11/06, Richard Lynch <[EMAIL PROTECTED]> wrote: On Fri, November 3, 2006 5:30 am, Dotan Cohen wrote: > To all others who took part in this thread: I was unclear on another > point as well, the issue of sql-injection. As I'm removing the > symbols, signs, and other non-alpha characters from

Re: [PHP] str_replace on words with an array

2006-11-03 Thread Richard Lynch
On Fri, November 3, 2006 5:30 am, Dotan Cohen wrote: > To all others who took part in this thread: I was unclear on another > point as well, the issue of sql-injection. As I'm removing the > symbols, signs, and other non-alpha characters from the query, I > expect it to be sql-injection proof. As I

Re: [PHP] str_replace on words with an array

2006-11-03 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2006-10-30 21:18:33 +: > Dotan Cohen wrote: > > $searchQuery=str_replace( "^".$noiseArray."$", " ", $searchQuery); > > Ok, this is what the compiler will see... > > $searchQuery=str_replace("^Array$", " ", $searchQuery); > > Yes, that's a literal Array in the string. Yo

Re: [PHP] str_replace on words with an array

2006-11-03 Thread Dotan Cohen
On 31/10/06, Larry Garfield <[EMAIL PROTECTED]> wrote: From your original message, it sounds like you want to strip selected complete words, not substrings, from a string for indexing or searching or such. Right? I think that was my mistake- not differentiating between the two. Symbols and such

Re: [PHP] str_replace on words with an array

2006-10-30 Thread Ed Lazor
On Oct 30, 2006, at 1:10 PM, Dotan Cohen wrote: On 30/10/06, Stut <[EMAIL PROTECTED]> wrote: Ed Lazor wrote: > It looks like you guys are coming up with some cool solutions, but I > have a question. Wasn't the original purpose of this thread to > prevent sql injection attacks in input from

Re: [PHP] str_replace on words with an array

2006-10-30 Thread Larry Garfield
On Monday 30 October 2006 15:10, Dotan Cohen wrote: > Er, so how would it be done? I've been trying for two days now with no > success. From your original message, it sounds like you want to strip selected complete words, not substrings, from a string for indexing or searching or such. Right?

Re: [PHP] str_replace on words with an array

2006-10-30 Thread Ed Lazor
On Oct 30, 2006, at 9:19 AM, Stut wrote: Ed Lazor wrote: It looks like you guys are coming up with some cool solutions, but I have a question. Wasn't the original purpose of this thread to prevent sql injection attacks in input from user forms? If so, wouldn't mysql_real_escape_string b

Re: [PHP] str_replace on words with an array

2006-10-30 Thread Stut
Dotan Cohen wrote: > Er, so how would it be done? I've been trying for two days now with no > success. Ok, I guess my original reply didn't get through, or you ignored it. Here it is again for your convenience. Dotan Cohen wrote: > > $searchQuery=str_replace( "^".$noiseArray."$", " ", $searchQuer

Re: [PHP] str_replace on words with an array

2006-10-30 Thread Dotan Cohen
On 30/10/06, Stut <[EMAIL PROTECTED]> wrote: Ed Lazor wrote: > It looks like you guys are coming up with some cool solutions, but I > have a question. Wasn't the original purpose of this thread to > prevent sql injection attacks in input from user forms? If so, > wouldn't mysql_real_escape_stri

Re: [PHP] str_replace on words with an array

2006-10-30 Thread Stut
Ed Lazor wrote: It looks like you guys are coming up with some cool solutions, but I have a question. Wasn't the original purpose of this thread to prevent sql injection attacks in input from user forms? If so, wouldn't mysql_real_escape_string be an easier solution? Me thinkie nottie. From

Re: [PHP] str_replace on words with an array

2006-10-30 Thread Ed Lazor
It looks like you guys are coming up with some cool solutions, but I have a question. Wasn't the original purpose of this thread to prevent sql injection attacks in input from user forms? If so, wouldn't mysql_real_escape_string be an easier solution? On Oct 30, 2006, at 8:17 AM, Jochem

Re: [PHP] str_replace on words with an array

2006-10-30 Thread Jochem Maas
Dotan Cohen wrote: > I need to remove the noise words from a search string. I can't seem to > get str_replace to go through the array and remove the words, and I'd > rather avoid a redundant foreach it I can. According to TFM > str_replace should automatically go through the whole array, no? Does >

Re: [PHP] str_replace on words with an array

2006-10-30 Thread Jochem Maas
Dotan Cohen wrote: > I need to remove the noise words from a search string. I can't seem to > get str_replace to go through the array and remove the words, and I'd > rather avoid a redundant foreach it I can. According to TFM > str_replace should automatically go through the whole array, no? Does >

Re: [PHP] str_replace on words with an array

2006-10-29 Thread Ed Lazor
checkout the function mysql_real_escape_string() On Oct 29, 2006, at 3:13 PM, Dotan Cohen wrote: On 30/10/06, Paul Novitski <[EMAIL PROTECTED]> wrote: Hi Dotan, To get help with your problem, share more of your PHP code with the list so we can look at what you're doing. Also, give us a link

Re: [PHP] str_replace on words with an array

2006-10-29 Thread Dotan Cohen
On 30/10/06, Paul Novitski <[EMAIL PROTECTED]> wrote: Hi Dotan, To get help with your problem, share more of your PHP code with the list so we can look at what you're doing. Also, give us a link to the PHP script on your server so we can see the output. Regards, Paul Nothing else is relevan

Re: [PHP] str_replace on words with an array

2006-10-29 Thread Stut
Dotan Cohen wrote: > Thanks all for the heads up with the str_replace not working with > regexes. Duh! I've switched to preg_replace, but still no luck. (nor > skill, on my part) > > I'm trying to use array_walk to go through the array and deliminate > each item with /b so that the preg_replace fu

Re: [PHP] str_replace on words with an array

2006-10-29 Thread Dotan Cohen
Thanks all for the heads up with the str_replace not working with regexes. Duh! I've switched to preg_replace, but still no luck. (nor skill, on my part) I'm trying to use array_walk to go through the array and deliminate each item with /b so that the preg_replace function will know to only opera

Re: [PHP] str_replace on words with an array

2006-10-29 Thread Paul Novitski
Paul Novitski wrote: If you go this route, perhaps you could enclose each member of your original array in \b word boundary sequences using an array_walk routine so that you don't have to muddy your original array declaration statement. At 10/29/2006 01:54 PM, rich gray wrote: IIRC str_repl

Re: [PHP] str_replace on words with an array

2006-10-29 Thread Dotan Cohen
On 29/10/06, Børge Holen <[EMAIL PROTECTED]> wrote: Yes you need to put some \ in front of some of those characters On Sunday 29 October 2006 21:05, Dotan Cohen wrote: > I need to remove the noise words from a search string. I can't seem to > get str_replace to go through the array and remove th

Re: [PHP] str_replace on words with an array

2006-10-29 Thread Stut
Dotan Cohen wrote: > $searchQuery=str_replace( "^".$noiseArray."$", " ", $searchQuery); Ok, this is what the compiler will see... $searchQuery=str_replace("^Array$", " ", $searchQuery); Yes, that's a literal Array in the string. You cannot, and you should remember this, you cannot concatenate st

Re: [PHP] str_replace on words with an array

2006-10-29 Thread rich gray
Paul Novitski wrote: If you go this route, perhaps you could enclose each member of your original array in \b word boundary sequences using an array_walk routine so that you don't have to muddy your original array declaration statement. IIRC str_replace() does not interpret or understand re

Re: [PHP] str_replace on words with an array

2006-10-29 Thread Myron Turner
I never use this function, since I always use regular expressions, but according to the manual: If you don't need fancy replacing rules (like regular expressions), you should always use this function instead of ereg_replace() or preg_replace(). So, I assume your problem

Re: [PHP] str_replace on words with an array

2006-10-29 Thread Paul Novitski
At 10/29/2006 01:07 PM, Dotan Cohen wrote: The purpose of the ^ and the $ is to define the beginning and the end of a word: http://il2.php.net/regex No, actually, ^ and $ define the beginnning & end of the entire expression being searched, not the boundaries of a single word. Therefore sea

Re: [PHP] str_replace on words with an array

2006-10-29 Thread Dotan Cohen
On 29/10/06, Alan Milnes <[EMAIL PROTECTED]> wrote: Dotan Cohen wrote: > $searchQuery=str_replace( "^".$noiseArray."$", " ", $searchQuery); Can you explain what you are trying to do with the ^ and $? What is a typical value of the original $searchQuery? Alan The purpose of the ^ and the $ is

Re: [PHP] str_replace on words with an array

2006-10-29 Thread Børge Holen
Yes you need to put some \ in front of some of those characters On Sunday 29 October 2006 21:05, Dotan Cohen wrote: > I need to remove the noise words from a search string. I can't seem to > get str_replace to go through the array and remove the words, and I'd > rather avoid a redundant foreach it