Page 1 of 1

Help!

Posted: Wed May 26, 2004 10:00 am
by idnoble
Hello
I am trying to create a script that use the variable passed to it from an HTML form to search 2 tables in my database and display the results from both tables, i have created the script but each time i run i always get this error message:

Parse error: parse error in /var/www/html/search.php on line 545

I think its a problem with the query PHP is passing to mysql, i've looked through the code but can't figure it our, please help :( :( , My code is below

Code: Select all

<?php
//Create short variable names
$search = $HTTP_POST_VARS['search'];
$search= trim($search);
if (!$search)
{
echo '<p style= "font-size: 15pt color: red"><strong>You have not specified a search term. Please go back and try again.</strong></p>';
exit;
}
$search = addslashes($search);
$session = mysql_connect('localhost', '', '') or die(mysql_error());
if (!$session)
{
echo 'Error: Could not connect to database. Please try again later.';
exit;
}

mysql_select_db('xplosive')or die(mysql_error());
$query = "select * 
from movies, music
where movies.Title like '%".$search."%'", && music.Title like '%".$search.'%";
$result = mysql_query($query) or die(mysql_error()); 

$num_results = mysql_num_rows($result);

echo '<p style= "font-size: 10pt"><strong>Search hits: '.$num_results.'></strong></p>';
for ($i=0; $i <$num_results; $i++)
{
 $row = mysql_fetch_array($result);
echo '<p style= "font-size:14pt; color: blue"><strong>'. ($i+1). ':'; 
echo htmlspecialchars (stripslashes($row['Title']));
 echo '<p style= "font-size: 12pt; color: black"<br />Genre: ';
 echo stripslashes($row['Genre']);
 echo '<br/> Synopsis: ';
 echo stripslashes ($row['Synopsis']);
 echo'<br> Price: ';
 echo stripslashes ($row['Price']);
 echo '<br> Cat Number: ';
 echo stripslashes ($row['Cat_No']);
 echo '</p>';

Posted: Wed May 26, 2004 10:02 am
by jason
1. Help!!!!!!!!!!!!!!! is not a appropriate subect line. Don't do it.
2. Look at the colored PHP code. Specifically, around here:

Code: Select all

$query = "select *
from movies, music
where movies.Title like '%".$search."%'", && music.Title like '%".$search.'%";

Posted: Wed May 26, 2004 10:02 am
by magicrobotmonkey
hmm... look at the colors of your code - for some reason about halfway down it all turns red for string! That's a clue...

Posted: Wed May 26, 2004 10:11 am
by kettle_drum
Which line is 545?

Try editing this:

Code: Select all

$query = "select * 
from movies, music 
where movies.Title like '%".$search."%'", && music.Title like '%".$search.'%";
to

Code: Select all

$query = "SELECT * FROM movies, music WHERE movies.Title LIKE '%$search%' AND music.Title LIKE '%$search%'";