mike2098
12-23-2009, 01:47 PM
Hi I hope somone can help I am getting a parse error at the end of my script I have gone through and checked all the code but just can't find the problem
my code :
<?php
//include("header.php");
include("conf.php");
?>
<div id="container2">
<div id="content"><br />
<form action="search.php" method="GET">
Search Site:
<input type="text" name="q" />
<input type="submit" name="search class="submit-btn" src="btn.gif" alt="submit" title="submit" />
</form>
<br />
<br />
<?php
if (count($_POST) > 0) {
$search = trim(strtoupper($_POST['q']));
mysql_select_db ("db_search")
or die ("Cannot connect to the database");
//run query on database where search value is like table fields
$sql .= "SELECT * FROM articles where ( ";
$sql .= " UPPER(title) like '%" . $search . "%' OR ";
$sql .= " UPPER(category) like '%" . $search . "%' OR ";
$sql .= " UPPER(body) like '%" . $search . "%' ";
$sql .= ") order by category";
$q = (mysql_query($sql));
echo $q;
$num_rows = mysql_num_rows($q); ///check no of rows
// while there are rows echo output to produce page of results
if($num_rows>0){
while($d = mysql_fetch_array($q)){
$id = $d['id'];
$title = $d['title'];
$category = $d['category'];
$body = $d['body'];
echo "<div class=\"response\"><p><strong>" . $title . "</strong></p>";
//include("resultsheader.php");
echo $id . ' - ';
echo '<br>';
echo 'Category: ' . $category . '<br>';
echo '<br>';
echo 'Body: ' . $body . '<hr>';
echo '</div>';
}
//end while loop
}else{
echo"<p>Sorry, no search result. Please change keywords and try again.</p>";
//end if
?>
Thanks
M
my code :
<?php
//include("header.php");
include("conf.php");
?>
<div id="container2">
<div id="content"><br />
<form action="search.php" method="GET">
Search Site:
<input type="text" name="q" />
<input type="submit" name="search class="submit-btn" src="btn.gif" alt="submit" title="submit" />
</form>
<br />
<br />
<?php
if (count($_POST) > 0) {
$search = trim(strtoupper($_POST['q']));
mysql_select_db ("db_search")
or die ("Cannot connect to the database");
//run query on database where search value is like table fields
$sql .= "SELECT * FROM articles where ( ";
$sql .= " UPPER(title) like '%" . $search . "%' OR ";
$sql .= " UPPER(category) like '%" . $search . "%' OR ";
$sql .= " UPPER(body) like '%" . $search . "%' ";
$sql .= ") order by category";
$q = (mysql_query($sql));
echo $q;
$num_rows = mysql_num_rows($q); ///check no of rows
// while there are rows echo output to produce page of results
if($num_rows>0){
while($d = mysql_fetch_array($q)){
$id = $d['id'];
$title = $d['title'];
$category = $d['category'];
$body = $d['body'];
echo "<div class=\"response\"><p><strong>" . $title . "</strong></p>";
//include("resultsheader.php");
echo $id . ' - ';
echo '<br>';
echo 'Category: ' . $category . '<br>';
echo '<br>';
echo 'Body: ' . $body . '<hr>';
echo '</div>';
}
//end while loop
}else{
echo"<p>Sorry, no search result. Please change keywords and try again.</p>";
//end if
?>
Thanks
M