Re: Replacing * with %

From: Date: Tue, 15 Jan 2002 11:14:07 +0000
Subject: Re: Replacing * with %
References: 1 2  Groups: php.db 
Request: Send a blank email to php-db+get-15819@lists.php.net to get a copy of this message
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" <pereti@ump.edu.br> To: "PHP-DB" <php-db@lists.php.net> 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" <markus.lervik@vaasa.fi> > To: <php-db@lists.php.net> > 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 > > markus.lervik@vaasa.fi > > +358-6-325 3589 / +358-40-832 6709 > > > > -- > > PHP Database Mailing List (http://www.php.net/) > > To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net > > For additional commands, e-mail: php-db-help@lists.php.net > > To contact the list administrators, e-mail: php-list-admin@lists.php.net > > > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net > For additional commands, e-mail: php-db-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.db (#15819) next »