Jump to content

drawrof

Members
  • Posts

    10
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

drawrof's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. sorry if this is a stupid question or something. however, i would greatly appreciate a bit of help or direction. thank you!
  2. so, i've a little search engine set up to query a database. however, i have some entries in my db with foreign characters. what can i do to make these foreign characters searchable with regular english characters? for example, someone searches "fur elise" and the query will find "für elise" thanks.
  3. ahh jeez. that's embarrassing. thanks.
  4. here's the full script. <html><form name="form" action="test.php" method="get"> <div align="center"> <p> <input name="q" type="text" value="soulmates!"> by <select name="field"> <Option VALUE="band">band</option> <Option VALUE="title">song title</option> <Option VALUE="lyrics">lyrics</option> </select> <input name="Submit" type="submit" class="submit" value="search!"> </p> </div> </form></html> <?php // Get the search variable from URL $var = @$_GET['q'] ; $search = trim($var); $trimmed="%".$search."%"; // check for an empty string and display a message. if ($trimmed == "") { echo ""; exit; } // check for a search parameter if (!isset($var)) { echo "<p>you didn't enter anything useful!</p>"; exit; } //connect to db mysql_connect("localhost","user","password"); //(host, username, password) //specify database ** EDIT REQUIRED HERE ** mysql_select_db("ihear6_songs") or die("Unable to select database"); //select which database we're using // Build SQL Query if ( $field == "lyrics" ) { $query = "SELECT lyrics, MATCH(lyrics) AGAINST (\"%$trimmed%\" IN BOOLEAN MODE) AS score FROM songs WHERE MATCH(lyrics) AGAINST (\"%$trimmed%\" IN BOOLEAN MODE) ORDER BY score DESC"; } elseif ($field == "band") { $query = "select * from songs WHERE band LIKE '$trimmed'"; } elseif ($field == "title") { $query = "select * from songs WHERE title LIKE '$trimmed' || filename LIKE '$trimmed'"; } else { echo "<p>uh oh! there seems to be a problem, dear.<p>"; } $numresults=mysql_query($query); $numrows=mysql_num_rows($numresults); // If we have no results... if ($numrows == 0) { echo "<p>sorry, dear! i couldn't find anything matching your search!</p>"; } // next determine if s has been passed to script, if not use 0 if (empty($s)) { $s=0; } // get results $result = mysql_query($query) or die("Couldn't execute query"); // display what the person searched for echo "<p>you searched for: <strong>" . $var . "</strong></p>"; // begin to show results set $count = 1 + $s ; // now you can display the results returned while ($row= mysql_fetch_array($result)) { $title = $row["title"]; $folder = $row["folder"]; $band = $row["band"]; $filename = $row["filename"]; echo "<p><strong>$count) </strong><a class=\"songs\" href=\"http://songs.iheartadelie.org/songs/$link\">$title</a></p>" ; $count++ ; } //break before paging echo "<br/>"; ?>
  5. perhaps it's something with my if else statement. i'm getting a "query was empty" statement from that error check. also, when i insert any query by itself without the if-else then it works quite well. sorry. i'm rather new (not the first time you've heard that eh?)
  6. i'm making a simple search which will search certain parts of a db depending on what the person wants. they choose whether they want to search bands, title, or lyrics through and option menu. but i keep getting this: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/ihear6/public_html/test.php on line 107 here's the problem area in the php // Build SQL Query if ( $field == "lyrics" ) { $query = "SELECT lyrics, MATCH(lyrics) AGAINST (\"%$trimmed%\" IN BOOLEAN MODE) AS score FROM songs WHERE MATCH(lyrics) AGAINST (\"%$trimmed%\" IN BOOLEAN MODE) ORDER BY score DESC"; } elseif ($field == "band") { $query = "select * from songs WHERE band LIKE '$trimmed'"; } elseif ($field == "title") { $query = "select * from songs WHERE title LIKE '$trimmed' || filename LIKE '$trimmed'"; } else { echo "<p>uh oh! there seems to be a problem, dear.<p>"; } $numresults=mysql_query($query); $numrows=mysql_num_rows($numresults); thanks.
  7. is there any way around this stopword list besides modifying the mysql install?
  8. http://iheartadelie.org/test.php thanks. i can supply the php if necessary... perhaps it has something to do with that being in the stopword file?
  9. 5.0.27-standard okay. i'm very new. but i've managed to created this simple search script that is running off of a database. it's based on the search engine script here with a few others. boolean searching. anyways, everything works okay. except when i search for the word "last". when i do that, it says it found no results. any ideas? Table structure for table songs Field Type Null Default title varchar(255) Yes link varchar(255) Yes Dumping data for table songs water from the same source tttt last things last tttt from water fff poop from poop sdfaf last things last yes last last s fast fast f fast last l list list
×
×
  • 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.