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
https://forums.phpfreaks.com/topic/32132-solved-mysql-asearch/
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
https://forums.phpfreaks.com/topic/32132-solved-mysql-asearch/#findComment-149102
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
https://forums.phpfreaks.com/topic/32132-solved-mysql-asearch/#findComment-149105
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.