Results 1 to 2 of 2

Thread: Search Script not working...

  1. #1

    Thread Starter
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    Search Script not working...

    ok, i got this off of a tutorial as well. it seems thoes scripts are old

    it gives me the following error:
    Code:
    Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /usr/home/homtek/public_html/dclamp/results.php on line 15
    Here be the code:
    PHP Code:
    <html>
    <head>
     <title>Search Results</title>
    </head>

    <body>
     <h2>Search Results</h2>
    <br>

    <?
        $dbh=mysql_connect ("localhost", "homtek_dclamp", "moiola");
        mysql_select_db ("homtek_HomTekSQL1"); 
        $query = "SELECT * FROM users WHERE user LIKE '%".$name."%'";
        $result = mysql_query($query);
        while ($record = mysql_fetch_assoc($result)) {
            while (list($fieldname, $fieldvalue) = each ($record)) {
                echo $fieldname.": <b>".$fieldvalue."</b><br>";
            }
            echo "<br>";
        }
    ?>
    <br>
    <a href="search.html">Click here to go back to the search page</a>
    </body>
    </html>
    it starts on: http://dclamp.homtek.net/search.html
    My usual boring signature: Something

  2. #2
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Search Script not working...

    You have a query error or zero result set.
    Use mysql_error() to get the error message.

    PHP Code:
    $result mysql_query($query);
    if (!
    is_resource($result))
      die(
    mysql_error()); 
    Don't use die() in a production situation though.

Posting Permissions

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



Click Here to Expand Forum to Full Width