SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Zealot
    Join Date
    Aug 2005
    Posts
    166
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Search results and processing question...

    I'm creating a basic search engine for finding artists in my database. When a user searches, I record the search in my database (for user behavior tracking) on process_search.php and then redirect to search.php (passing the variable between URL's, of course). For some reason, what I have below isn't passing the variable between process_search.php and search.php. Can someone have a look at the code and tell me what I'm doing wrong?

    Here's the search form (index.php)...
    PHP Code:
    <form name="search" action="process_search.php" method="post">
    <input type="hidden" name="action">
    <input type=radio name=stype value="artist" checked>&nbsp;Artist
    <input name="query" type="text" size="15" maxlength="35" value="<? echo stripslashes($lower_query); ?>">
    <input type="submit" value="Go">
    </form>
    This processes the search... (process_search.php)
    PHP Code:
     if (isset($_POST['query'])) {
       
    $user_id $_SESSION['user_id'];
       
    $query $_POST['query'];
       
    $sql "INSERT INTO search SET
           search_string='
    $query', search_dateadded= NOW(), user_id='$user_id'";
       if (@
    mysql_query($sql)) {
         
    header('Location: search.php?q="' stripslashes($query) . '"');
       } else {
         echo 
    '<p>Error recording search: ' .
             
    mysql_error() . '</p>';
       }
     } 
    I use this query to bring back the search results... (search.php)
    PHP Code:
    $query strtolower($_GET['q']);
    $search_artists mysql_query("SELECT * FROM artist WHERE artist_name LIKE '%$query%' OR artist_aliases LIKE '%$query%' AND artist_status='' ORDER BY artist_name ASC"); 
    I have a feeling it's something very small but I can't seem to put my finger on it .

    Thanks in advance, SitePoint.

  2. #2
    SitePoint Evangelist nsj's Avatar
    Join Date
    Oct 2005
    Location
    Jamaica (W.I)
    Posts
    447
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What's the purpose of this?
    <input type="hidden" name="action">

  3. #3
    SitePoint Zealot
    Join Date
    Aug 2005
    Posts
    166
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by nsj
    What's the purpose of this?
    <input type="hidden" name="action">
    It doesn't have one . I don't know how that slipped in there.

  4. #4
    SitePoint Enthusiast shref's Avatar
    Join Date
    Nov 2004
    Location
    Egypt, Alexandria
    Posts
    99
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    header('Location: search.php?q=" ' . stripslashes($query) . ' " ');
    you are using double quotes !!
    Shreef
    blog: shreef.com
    twitter: @shreef

  5. #5
    SitePoint Zealot
    Join Date
    Aug 2005
    Posts
    166
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ^ That doesn't fix it. Any other ideas?

    *NM, I figured this out...please ignore.
    Last edited by Confusion; Nov 20, 2005 at 22:56.


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
  •