Results 1 to 3 of 3

Thread: Parse error

  1. #1
    Join Date
    Dec 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Parse error

    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 :
    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

  2. #2
    Join Date
    May 2007
    Location
    Boston,ma
    Posts
    2,127
    Thanks
    173
    Thanked 207 Times in 205 Posts

    Default

    Your last line missing }

    else{
    echo"<p>Sorry, no search result. Please change keywords and try again.</p>";
    //end if
    }
    ?>

  3. #3
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Also, when posting about an error, please include the exact error you get so we know what to look for.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •