|
Posted by BKDotCom on 12/26/06 17:39
thecoolone wrote:
> here is the code:
> if($_GET['query']==new)
is new a constant?! PHP will certainly think so. Put quotes around
your strings!
if( $_GET['query'] == 'new' )
> { filter($query);}
> elseif($_GET['query']==some'u'all)
// same problem here. I'm sure your error-log is full of run-time
errors. There's no way this script compiled.
elseif( $_GET['query' ]== 'some\'u\'all' )
> { filter($query);}
> elseif($_GET['query']==all'u'ppl)
same problem
> { filter($query);}
>
> function filter($query)
> {
> $pattern = array ('/new/','/some'u'all/','/all'u'ppl/');
escape your quotes
$pattern = array ('/new/','/some\'u\'all/','/all\'u\'ppl/');
> $rep = array ("new way","Some of you all ","all of you");
> $op = preg_replace($pattern,$rep,$_GET['query']);
why are you using regular expressions? Just use str_replace
> echo "<br>new value $op";
> }
>
>
> also i wanted to just clarify is there a way of using multiple OR's in
> the same "if" condition
> i.e if(($_GET['query]')==new||newday||newtime||newbeginning||newthing)
well, you can do this:
if (
in_array($_GET['query'],array('new','newday','newtime','newbeginning','newthing'))
)
{
}
Navigation:
[Reply to this message]
|