By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,830 Members | 2,271 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,830 IT Pros & Developers. It's quick & easy.

Help With PHP Preg_match to search

P: 1
I'm trying to create a search function for my site and I can't ever seem to figure it out. If anybody could help, that would be awesome, because everything I try, I keep getting errors...

Here's my code so far.
<div style='display:none;'>
<title>The Movie List</title>
<body bgcolor = black>
<img src="moviep.jpg"><br>
<img name="image" src="image.gif" width="650" height="75" border="0" id="image" usemap="#m_image" alt="" /><map name="m_image" id="m_image">
<area shape="poly" coords="14,2,110,2,110,71,14,71,14,2" href="" alt="" />
<area shape="rect" coords="467,0,638,71" href="" alt="" />
<area shape="rect" coords="339,2,455,71" href="" alt="" />
<area shape="rect" coords="126,0,323,71" href="" alt="" />
<form action="Search.php" method="post">
<table border="0" bgcolor=white cellspacing="5">
<tr><td><font color=red>Search</font></td><td><input type="text" size="60" name="search"></td></tr>
<tr><td>&nbsp;</td><td><input type="submit" value="Send"><font face="arial" size="1">&nbsp;&nbsp;Click Send To Continue</font></td></tr>
<font color = red>


$Movie = file_get_contents('Movies.txt');

function title_cmp($a, $b)
$a_cmp = preg_replace('/^(A|An|The) /', '', $a['Title']);
$b_cmp = preg_replace('/^(A|An|The) /', '', $b['Title']);

return strcmp($a_cmp, $b_cmp);

usort($Movie, 'title_cmp');

if($_POST['search'] =! '')
$search = $_POST['search'];

foreach($Movie as $key =>$val)
if(preg_match(strtolower($search), strtolower($Movie[$key][Title])));
echo $Movie[$key][Title].'<br>';



The error I keep receiving is:

Warning: preg_match() [function.preg-match]: Delimiter must not be alphanumeric or backslash in E:\Tyson\wamp\www\jedit\Test1\Search.php on line 49 #
And that repeats over and over again for each value within my array...

This is what the file looks like that I'm getting data from:

Movie[1][Title]=Troy&Movie[1][Genre]=Action / Drama / History /

Romance&Movie[2][Title]=Mr. and Mrs. Smith&Movie[2][Genre]=Action /

Comedy / Romance / Thriller
I have no idea how to get this to any help would be amazing! Thank you so much!
Feb 25 '07 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.