Jump to content

[SOLVED] MySQL asearch


ki

Recommended Posts

Okay, well I know the search result I have this code, but nothing comes up when i know there are posts in which it contains, say take a look and tell me whats wrong here.

[code]if(isset($HTTP_POST_VARS['submit'])) {

if(!$_POST['search']) {
header("Location: ?page=forum&sub=search");
die();
}
$searchterm = $_POST['search'];
$query = mysql_query("SELECT * FROM `forum_threads` WHERE `text` LIKE %$searchterm%");
while($search = mysql_fetch_object($query)) {
echo $search->id;
}

} else {

echo "<form method=\"POST\" action=\"?page=forum&sub=search\">";
echo "<input type=\"text\" name=\"search\" id=\"search\">";
echo "<input type=\"submit\" name=\"submit\" id=\"submit\">";
echo "</form>";

}[/code]
Link to comment
Share on other sites

[code]
if(isset($_POST['submit'])) {

if(!isset($_POST['search'])) {
header("Location: ?page=forum&sub=search");
die();
}else {
$searchterm = $_POST['search'];
$query = mysql_query("SELECT * FROM `forum_threads` WHERE `text` LIKE %$searchterm%");
while($search = mysql_fetch_object($query)) {
echo $search->id;
}
mysql_free_result($query)
}

} else {

echo "<form method=\"POST\" action=\"?page=forum&sub=search\">";
echo "<input type=\"text\" name=\"search\" id=\"search\">";
echo "<input type=\"submit\" name=\"submit\" id=\"submit\">";
echo "</form>";

}
[/code]
Link to comment
Share on other sites

thanks for the response but i get this error

Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in /home/tragical/public_html/index.php on line 422

Warning: mysql_free_result(): supplied argument is not a valid MySQL result resource in /home/tragical/public_html/index.php on line 425
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.