Parse error: syntax error, unexpected '<' in D:\Program Files\wamp\www\mysite\drupal-6.3\includes\common.inc(1547)

rcdimalanta - December 2, 2008 - 13:17

I want to create a search engine for the student and alumni directory in my student information system. But after i save the code below, this message always comes Parse error: syntax error, unexpected '<' in D:\Program Files\wamp\www\mysite\drupal-6.3\includes\common.inc(1547) What will I do???? Can you give me some way how my search engine will work??? Thanks in advance!

<?php
<head>
$var = @$_GET['q'] ;
$trimmed = trim($var);

$user = "admin";
$password = "chad2008";
$host = "localhost";
$dbase = "alumnidirectory";
$table = "alumni_info";

mysql_connect($localhosthost,$admin,$chad2008);
@
mysql_select_db($alumnidirectory) or die("Unable to select database");

$surname = "Name";

$query = "SELECT * FROM $alumni_info WHERE $surname LIKE "%$trimmed%" order by alum_no";


$result = mysql_query($query);
</
head>
<
form name="search" method="GET" action="<?=$PHP_SELF
?>
">

Seach the database for:

$count =mysql_numrows($result);

if($q == true)

{

exit;

}

elseif($q == false)

{

">

Seach all the newsletters for

}

if ($trimmed == "")

{

echo "

Please enter a search...

";

exit;

}

// check for a search parameter

if (!isset($var))

{

echo "

We dont seem to have a search parameter!

";

exit;

}

$numresults=mysql_query($query);

$numrows=mysql_num_rows($numresults);

if ($numrows == 0)

{

echo "

Results

";

echo "

Sorry, your search: "" . $trimmed . "" returned zero results

";

}

// next determine if s has been passed to script, if not use 0

if (empty($s))

{

$s=0;

}

$result = mysql_query($query) or die("Couldn't execute query");

if($numrows > 1){ $return = "results";}

else{ $return = "result"; }

echo "

Your search for "" . $var . "&quot returned $numrows $return.

";

$count = 1 + $s ;

while ($r= mysql_fetch_array($result))

{

$surname = $r["surname"];

$firstname = $r["firstname"];

$course = $r["course"];

$batch = $r["batch"];

$work_ad = $r["work_ad"];

$count++ ;

?>

<? echo $surname ?>,<? echo $firstname ?>
<? echo $course ?>,<? echo $batch ?>

<? echo $work_ad ?>

<? } ?>

I assume you are putting

gpk - December 2, 2008 - 15:33

I assume you are putting this code in a node with PHP input format.

Well the above code hasn'd displayed properly but it looks as though you are including HTML elements within the PHP tags - I see opening and closing head tags, a form tag etc. These need to be outside the PHP tags, which you can keep closing and reopening as necessary to achieve this.

gpk
----
www.alexoria.co.uk

 
 

Drupal is a registered trademark of Dries Buytaert.