Wrox Programmer Forums
|
BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0
This is the forum to discuss the Wrox book Beginning PHP5, Apache, and MySQL Web Development by Elizabeth Naramore, Jason Gerner, Yann Le Scouarnec, Jeremy Stolz, Michael K. Glass; ISBN: 9780764579660
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 12th, 2008, 03:36 PM
Registered User
 
Join Date: Jun 2008
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Search Error Chapter 16

I get this error when searching within the forum script.

SQL: SELECT *, MATCH (subject,body) AGAINST ('test') AS score FROM forum_posts WHERE MATCH (subject,body) AGAINST ('test') ORDER BY score DESC

I didn't modify anything either.

search.php
Code:
<?php
require_once 'conn.php';
require_once 'functions.php';
require_once 'header.php';

$result = NULL;

if (isset($_GET['keywords'])) {
  $sql = "SELECT *, MATCH (subject,body) " .
         "AGAINST ('" . $_GET['keywords'] . "') AS score " .
         "FROM forum_posts " .
         "WHERE MATCH (subject,body) " .
         "AGAINST ('" . $_GET['keywords'] . "') " .
         "ORDER BY score DESC";

  $result = mysql_query($sql, $conn)
    or die('Could not perform search; ' . mysql_error());
}

echo "<table class=\"forumtable\" width=\"100%\" " .
     "cellspacing=\"0\">\n";
echo "<tr><th class=\"searchHeader\">Search Results</th></tr>\n";

if ($result and !mysql_num_rows($result)) {
  echo "<tr class=\"row1\"><td>No articles found that match the ";
  echo "search term(s) '<strong>" . $_GET['keywords'] . "</strong>'";
  if ($access_lvl > 2) echo "<p>SQL: $sql</p>";
  echo "</td></tr>\n";
} else {
  $rowclass = "";
  while ($row = mysql_fetch_array($result)) {
    $rowclass = ($rowclass == "row1"?"row2":"row1");
    echo "<tr class=\"$rowclass\">\n<td>\n";
    $topicid=($row['topic_id']==0?$row['id']:$row['topic_id']);
    echo "<p class=\"searchSubject\">\n<a href=\"viewtopic.php?t=" .
         $topicid . "#post" . $row['id'] . "\">" .
         $row['subject'] . "</a>\n";
    echo "</p>\n";
    echo "<p class=\"searchBody\">\n";
    echo htmlspecialchars(trimBody($row['body']));
    if ($access_lvl > 2) {
         echo "<p>SQL: $sql</p>";
         echo "<br><br>relevance: " . $row['score'];
    }
    echo "\n</p>\n";
    echo "</td>\n</tr>\n\n";
  }
}
echo "</table>";

require_once 'footer.php';
?>





Similar Threads
Thread Thread Starter Forum Replies Last Post
Error in Source Code in Chapter 16 Lcstyle BOOK: Beginning Linux Programming, 4th Edition ISBN 978-0-470-14762-7 1 February 28th, 2009 10:14 AM
Chapter 16 Sql connection error flashmanTom BOOK: Beginning Visual Basic 2005 ISBN: 978-0-7645-7401-6 1 May 22nd, 2008 05:04 PM
Chapter 16 forum - SQL error petefernando PHP Databases 3 October 22nd, 2007 07:13 PM
Chapter 16: search.php dhorn BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 0 April 5th, 2007 02:26 PM
Chapter 16 forum - SQL error petefernando Beginning PHP 2 March 31st, 2006 01:23 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.