Web Hosting Vodahost    

Home Take The Royal Tour! Order Now Features Prices
Go Back   Web Hosting > VodaHost Web Hosting Support > mySQL & PHP

Notices

mySQL & PHP Discussions, information and help with mySQL and PHP.

Reply
 
LinkBack Thread Tools
  #1  
Old 08-14-2007, 02:16 PM
Corporal
 
Join Date: Mar 2007
Posts: 13
Default error message on script

My domain is www.onitshabusinessdirectory.com

Please what is wrong with this searching script. the error message is:
Parse error: syntax error, unexpected T_STRING, expecting 'searchproduct/index.php on line 23



//after connection

//specify how many result to display per page
$limit=10;

//Get the search variable from URL
$var=@$_GET['q'];
//trim whitespace from the stored variables
$trimmed=trim($var);
//seperate key-phrases into key words
$trimmed_array=explode(" ",$trimmed);

//check for an empty string and display a message.
if(!isset($var)){
$resultmsg="<p>Search Error</p><p>We dont seem to have asearch parameter!</p>";
}
//Build SQL Query for keyword entered
for each ($trimmed_array as $trimm){

//Specify table and field names for the SQL query
$query="SELECT * FROM Onitsha Product Directory WHERE Business Location LIKE\"%$TRIMM%\" OR Type of Location LIKE \"%$TRIMM%\" OR Type of Business LIKE\"%$TRIMM%\" OR Category of Business LIKE\"%$TRIMM%\" ORDER BY ID DESC";
//Execute the query to get number of rows that contain search keywords
$numresults=mysql_query($query);
$row_num_links_main=mysql_num_rows($numresults);

//next determine if 's' has been passed to script, if not use 0.
//'s' is a variable that gets set as we navigate the search result pages.
if (empty($s)){
$s=0;
}

//now let's get the results.
$query="LIMIT$s,$limit";
$numresults=mysql_query($query)or die ("Couldn't execute query");
$row=mysql_fetch_array($numresults);

//store record id of every item that contains the keyword in the array we need to do this to avoid display of duplicate search result.
do{
$adid_array[]=$row['ID'];
}while($row=mysql_fetch_array($numresult));
}//end foreach

if($row_num_link_main==0 &&$row_set_num==0){
$resultmsg="<p>search result for:". $trimmed. "</p><p>sorry,your search returned zero result</p>;
}
//delete duplicate records id's from the array. to do this we will use array_unique function
$tmparr=array_unique($adid_array);
$i=0;
foreach ($tmparr as $v) {
$newarr[$i]=$v;
$i++;
}
//Let display the result. But first will will display the serch form on the top of the page
?>

<form action="search.php" method="get" name="search">
<div align="center">
<input name="q" type="text" value=<?php echo $q; ?> "size="15">
<input name="search" type=" submit value="search">
</div>
</form>

<?php
//display what the person searched for
if(isset($resultmsg)){
echo $resultmsg;
exit();
"
}else{
echo "Search result for: ".$var;
}

foreach($newarr as $value){

//specify table and field names for the SQL query
$query_value="SELECT *FROM Onitsha Product Directory WHERE ID='$value'";
$num_value=mysql_query($query_value);
$row_linkcat=mysql_fetch_array ($num_value);
$row_num_link=mysql_num_rows($num_value);

//making keywords bold
$titlehigh=preg_replace("'($var)'si","<b>\\1</b>",$row_linkcat['Business Location']);
$linkhigh=preg_replace("'($var)'si","<b>\\1</b>",$row_linkcat['Type of Location']);
$linkdesc=preg_replace("'($var)'si","<b>\\1</b>",$row_linkcat['Business Location']);
$titlehigh=preg_replace("'($var)'si","<b>\\1</b>",$row_linkcat['Type of Business']);
$titlehigh=preg_replace("'($var)'si","<b>\\1</b>",$row_linkcat['Category of Business']);

foreach($trimmed_array as $trimm){
if($trimm !='b'){

$titlehigh=preg_replace("'($trimm)'si","<b>\\1</b>",$titlehigh);
$linkhigh=preg_replace("'($trimm)'si","<b>\\1</b>",$linkhigh);
$linkdesc=preg_replace("'($trimm)'si","<b>\\1</b>",$linkdesc);
$titlehigh=preg_replace("'($trimm)'si","<b>\\1</b>",$titlehigh);
}

//end highlight

?>
<p>
<?php echo $titlehigh;?><br>
<?php echo $linkhigh;?><br>
<?php echo $linkhigh;?>
</p>

<?php
}//end for each $trimmed_array
if ($row_num_link_main>$limit){
//next we need to do the links to other search result pages
if ($s>1){//do not display previous link if 's' is'0'
$prevs=($s-$limit);
echo "<div align='left'>a href='$PHP_SEL?s=$prevs&q=$var&catid'>Previous" .$limit. "</a></div>";
}

//check to see if last page
$slimit=$s+$limit;
if(!($slimit>=$row_num_links_main)&& $row_num_links_main!=1) {
//not lat page so display next page
$n=$s+$limit;
echo"<div align='right'><a href='$PHP_SELF?s=$var&catid'>next" .$limit. "</></div>";
}
}
} //end foreach $newarr
?>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT +1. The time now is 07:39 PM.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC7
2007 VodaHost.com - All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55