i am trying to find multiple posts by using this code:


 // Connection Database
 $search = $_POST ['Search'];

mysql_connect("xxxxxx", "xxxxxx", "xxxxx") or die ("Error Connecting to Database");
mysql_select_db("xxxxx") or die('Error');
    $data = mysql_query("SELECT CourseName, CourseDescription, CourseLeader FROM course   MATCH (CourseName, CourseDescription, CourseLeader) AGAINST ('". $search ."')
or die('Error');
Print "<table border cellpadding=3>";
while($info = mysql_fetch_array( $data ))
  Print "<tr>";
  Print "<th>Course Name:</th> <td>".$info['CourseName'] . "</td> ";
  Print "<th>Course Description:</th><td>".$info['CourseDescription'] . "</td> ";
  Print "<th>Course Leader:</th><td>".$info['CourseLeader'] . " </td></tr>";

  Print "</table>";


i am obtaining the following error: Parse error: syntax error, unpredicted T_STRING in /home/a7105766/public_html/website/scripts/coursesearchdb.php online 30

what shall we be held doing wrong??


This lines are incorrect:

$data = mysql_query("SELECT ... AGAINST ('". $search ."') or die('Error');

You may also begin to see the error in the syntax highlighting that Stack Overflow uses. Would you use syntax highlighting when developing? Otherwise, I'd recommend it for catching exactly this kind of error.

The answer - you have to close the double-quote and also the open parenthesis.

$data = mysql_query("SELECT ... AGAINST ('". $search ."')") or die('Error');

Also rather than die('Error') you can write something helpful for example die(mysql_error()). You might take a look at trigger_error(mysql_error()).

Inside your SQL you're missing the keyword WHERE. See Full-Text Search Functions within the manual for additional info on full text searches.