469,613 Members | 1,252 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,613 developers. It's quick & easy.

Help With PHP Preg_match to search

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="http://tjjam4.farvista.net/Home.php" alt="" />
<area shape="rect" coords="467,0,638,71" href="http://tjjam4.farvista.net/Suggest.php" alt="" />
<area shape="rect" coords="339,2,455,71" href="http://tjjam4.farvista.net/The_Movie_List_Rev.php" alt="" />
<area shape="rect" coords="126,0,323,71" href="http://tjjam4.farvista.net/The_Movie_List.php" 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 work...so any help would be amazing! Thank you so much!
Feb 25 '07 #1
0 1641

Post your reply

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

Similar topics

2 posts views Thread by fartsniff | last post: by
2 posts views Thread by Muumac | last post: by
3 posts views Thread by ben | last post: by
2 posts views Thread by tgh003 | last post: by
5 posts views Thread by Mark Woodward | last post: by
3 posts views Thread by fienen | last post: by
3 posts views Thread by Happy Face | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.