There is an error in my script, % is not a special character (I got confused because of perl). So the correct is what Matt wrote.
<? $t = 'abc*cde*'; printf("%s\n", ereg_replace("\*", "%", $t)); ?> good luck, Bruno Pereti. ----- Original Message ----- From: "Bruno Gimenes Pereti" <[EMAIL PROTECTED]> To: "PHP-DB" <[EMAIL PROTECTED]> Sent: Tuesday, January 15, 2002 9:07 AM Subject: Re: [PHP-DB] Replacing * with % > Hi Markus, > > I think you forgot to assign the value of ereg_replace to a variable. I made > this test and it worked: > > <? > $t = 'abc*cde*'; > printf("%s\n", ereg_replace("\*", "\%", $t)); // or $result = > ereg_replace("\*", "\%", $t); > ?> > > Hope it helps, > > Bruno Pereti. > > ----- Original Message ----- > From: "Markus Lervik" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Tuesday, January 15, 2002 7:40 AM > Subject: [PHP-DB] Replacing * with % > > > > Hello all! > > > > I can't for the love of god get neither ereg_replace nor str_replace > > to work. I wan't to replace * with % so I can use SELECT ... WHERE > > whatever LIKE "string%" in MySQL. > > > > I've tried ereg_replace("*","%",$search_name). Didn't work. > > I tried escaping the asterisk. I tried double-escaping the asterisk. > > I tried str_replace("*","%",$search_name), and that didn't work > > either. I tried just about everything I could think of, escaping, double- > > escaping and triple-escaping ad nauseum, but it just wont work. > > > > Oh, yes, I also tried $search_name=ereg_replace(blablabla); > > What a surprise. It didn't work. > > > > Yes, I've RTFM, RTMFM, read from my PHP Blackbook to phpbuilder.net > > and just about everything in between. > > > > Pretty soon I'll start bashing away on that Solaris 8 box over there. > > > > > > Markus - frustrated > > > > -- > > Markus Lervik > > Linux-administrator with a kungfoo grip > > Vaasa City Library - Regional Library > > [EMAIL PROTECTED] > > +358-6-325 3589 / +358-40-832 6709 > > > > -- > > PHP Database Mailing List (http://www.php.net/) > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > To contact the list administrators, e-mail: [EMAIL PROTECTED] > > > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]