0

Hi,

I have a code snippet here as in the following:

if(preg_match("(Mon|Tue|Wed|Thu|Fri)/i", $keywords[$i])) {
   $day_query ="start_time.day='12345' AND end_time.day='12345'";  
   }  
   if(preg_match("Sat/i", $keywords[$i])) {
   $day_query = "start_time.Sat_route != 'NULL' AND end_time.Sat_route != 'NULL'";
   }  
   else {
   echo $keywords[i] . " is not a term that exists in the database. Make sure the pattern looks like <b>Mon, Tue</b><br />";
   footer();
   exit;
   }

For some reason, when I type in Mon, Tue

It gives me this:

Warning: preg_match() [function.preg-match]: Unknown modifier '/' in /var/www/Alice.Wei/web/instruction/trip_planner3.php on line 42

Warning: preg_match() [function.preg-match]: Delimiter must not be alphanumeric or backslash in /var/www/Alice.Wei/web/instruction/trip_planner3.php on line 45
is not a term that exists in the database. Make sure the pattern looks like Mon, Tue

Have I done something wrong here?
Thanks for your help.

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by MVied
0

It looks like you're missing the slash at the beginning of your regular expression.

preg_match("/(Mon|Tue|Wed|Thu|Fri)/i", $keywords[$i])

Edited by MVied: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.