Jump to content


Photo

Need help with a search script. *SOLVED*


  • Please log in to reply
13 replies to this topic

#1 pocobueno1388

pocobueno1388
  • Members
  • PipPipPip
  • Advanced Member
  • 3,369 posts
  • LocationPalm Beach, Florida

Posted 23 September 2006 - 12:55 AM

I have a couple of forms that the user can fill out that will search through the database and it will return results according to what they typed in.

The feilds they fill out are:

-Name (users input text)
-ID (users input numbers)
-Breed (This is a drop down box)
-For sale? (dropdown box that contains 'yes' or 'no')

I would like it to where they don't have to fill out all the fields, yet they will get the result they are looking for.
For example, if they know the name of the dog and just type in the name, I want it to pull that dog's name from the database.
I got the name and ID feilds to work, but I am not sure how to incorparate the 'breed' and 'for sale?' fields into my code.

Code:

<?php
include 'header.php';

if ($_POST['dogsearch']) {

$dogname = $_POST['dogname'];
$dogid = $_POST['dogid'];

	$result = mysql_query("SELECT dogID, name FROM dog WHERE name='$dogname' OR dogID='$dogid'");

	$row = mysql_fetch_assoc($result);




$sql_name_check = mysql_query("SELECT dogID, name FROM dog WHERE name='$dogname' OR dogID='$dogid'");

$name_check = mysql_num_rows($sql_name_check);




if($name_check == 0){

     print "<table width='40%' bgcolor='49614A'><td align='center' bgcolor='788D7A'><b>No such dog!</b></td></table></b>";
     
} else {


print<<<HERE

	<table width="90%" align="left">
	<td>

	<h2>Search Results:</h2><p>


	<a href="dog.php?id=$row[dogID]">$row[name] ($row[dogID])</a>

	</td></table>

HERE;

}
exit;
 }

print<<<HERE

	<table width="90%" align="left">
	<td>

	<h3>Search Dogs</h3>

	<form action="dogsearch.php?action=search" method="POST">
	Name:<br>
	<input type="text" name="dogname"><p>
	ID:<br>
	<input type="text" name="dogid" size=8><p>

<select name="breed">
<option value="">No Breed</option>
<option value="Afghan Hound">Afghan Hound</option>
<option value="Airedale Terrier">Airedale Terrier</option>
<option value="Alaskan Husky">Alaskan Husky</option>
<option value="Alaskan Malamute">Alaskan Malamute</option>
<option value="American Bulldog">American Bulldog</option>
<option value="American Eskimo Dog">American Eskimo Dog</option>
<option value="American Indian Dog">American Indian Dog</option>
<option value="American Pitbull Terrier">American Pitbull Terrier</option>
<option value="American White Shepherd">American White Shepherd</option>
<option value="Anatolian Shepherd">Anatolian Shepherd</option>
<option value="Australian Cattle Dog">Australian Cattle Dog</option>
<option value="Australian Koolie">Australian Koolie</option>
<option value="Australian Shepherd">Australian Shepherd</option>
<option value="Basenji">Basenji</option>
<option value="Basset Hound">Basset Hound</option>
<option value="Beagle">Beagle</option>
<option value="Bearded Collie">Bearded Collie</option>
<option value="Bedlington Terrier">Bedlington Terrier</option>
<option value="Belgian Malinois">Belgian Malinois</option>
<option value="Belgian Sheepdog">Belgian Sheepdog</option>
<option value="Belgian Tervuren">Belgian Tervuren</option>
<option value="Bernese Mountain Dog">Bernese Mountain Dog</option>
<option value="Bloodhound">Bloodhound</option>
<option value="Border Collie">Border Collie</option>
<option value="Border Terrier">Border Terrier</option>
<option value="Borzoi">Borzoi</option>
<option value="Boston Terrier">Boston Terrier</option>
<option value="Bouvier des Flandres">Bouvier des Flandres</option>
<option value="Boxer">Boxer</option>
<option value="Boykin Spaniel">Boykin Spaniel</option>
<option value="Briard">Briard</option>
<option value="Brittany Spaniel">Brittany Spaniel</option>
<option value="Brussels Griffon">Brussels Griffon</option>
<option value="Bull Terrier">Bull Terrier</option>
<option value="Bulldog">Bulldog</option>
<option value="Bullmastiff">Bullmastiff</option>
<option value="Cairn Terrier">Cairn Terrier</option>
<option value="Canaan Dog">Canaan Dog</option>
<option value="Cardigan Welsh Corgi">Cardigan Welsh Corgi</option>
<option value="Caucasian Ovtcharka">Caucasian Ovtcharka</option>
<option value="Chart Polski">Chart Polski</option>
<option value="Chesapeake Bay Retriever">Chesapeake Bay Retriever</option>
<option value="Chihuahua">Chihuahua</option>
<option value="Chinese Crested">Chinese Crested</option>
<option value="Chinese Shar-Pei">Chinese Shar-Pei</option>
<option value="Chinook">Chinook</option>
<option value="Chow-chow">Chow-chow</option>
<option value="Clumber Spaniel">Clumber Spaniel</option>
<option value="Cocker Spaniel">Cocker Spaniel</option>
<option value="Curly-Coated Retriever">Curly-Coated Retriever</option>
<option value="Dachshund">Dachshund</option>
<option value="Dalmatian">Dalmatian</option>
<option value="Doberman Pinscher">Doberman Pinscher</option>
<option value="Dutch Shepherd">Dutch Shepherd</option>
<option value="English Foxhound">English Foxhound</option>
<option value="English Mastiff">English Mastiff</option>
<option value="English Setter">English Setter</option>
<option value="English Shepherd">English Shepherd</option>
<option value="English Springer Spaniel">English SpringerSpaniel</option>
<option value="Eurasier">Eurasier</option>
<option value="Flat-Coated Retriever">Flat-Coated Retriever</option>
<option value="French Bulldog">French Bulldog</option>
<option value="German Pinscher">German Pinscher</option>
<option value="German Shepherd">German Shepherd</option>
<option value="German Shorthaired Pointer">German Shorthaired Pointer</option>
<option value="German Wirehaired Pointer">German Wirehaired Pointer</option>
<option value="Giant Schnauzer">Giant Schnauzer</option>
<option value="Golden Retriever">Golden Retriever</option>
<option value="Gordon Setter">Gordon Setter</option>
<option value="Great Dane">Great Dane</option>
<option value="Greater Swiss Mountain Dog">Greater Swiss Mountain Dog</option>
<option value="Greyhound">Greyhound</option>
<option value="Harrier">Harrier</option>
<option value="Havanese">Havanese</option>
<option value="Hovawart">Hovawart</option>
<option value="Irish Setter">Irish Setter</option>
<option value="Irish Terrier">Irish Terrier</option>
<option value="Irish Wolfhound">Irish Wolfhound</option>
<option value="Italian Greyhound">Italian Greyhound</option>
<option value="Jack Russel Terrier">Jack Russel Terrier</option>
<option value="Japanese Chin">Japanese Chin</option>
<option value="Kerry Blue Terrier">Kerry Blue Terrier</option>
<option value="Komondor">Komondor</option>
<option value="Labrador Retriever">Labrador Retriever</option>
<option value="Long-haired Collie">Long-haired Collie</option>
<option value="Maltese">Maltese</option>
<option value="Manchester Terrier">Manchester Terrier</option>
<option value="Maremma Sheepdog">Maremma Sheepdog</option>
<option value="Mastiff">Mastiff</option>
<option value="Miniature Australian Shepherd">Miniature Australian Shepherd</option>
<option value="Miniature Dachshund">Miniature Dachshund</option>
<option value="Miniature Pinscher">Miniature Pinscher</option>
<option value="Miniature Schnauzer">Miniature Schnauzer</option>
<option value="Old English Sheepdog">Old English Sheepdog</option>
<option value="Otterhound">Otterhound</option>
<option value="Papillon">Papillon</option>
<option value="Pekingese">Pekingese</option>
<option value="Pembroke Welsh Corgi">Pembroke Welsh Corgi</option>
<option value="Plott">Plott</option>
<option value="Pointer">Pointer</option>
<option value="Pomeranian">Pomeranian</option>
<option value="Poodle">Poodle</option>
<option value="Pug">Pug</option>
<option value="Rottweiler">Rottweiler</option>
<option value="Saarloos Wolfhound">Saarloos Wolfhound</option>
<option value="Saint Bernard">Saint Bernard</option>
<option value="Saluki">Saluki</option>
<option value="Samoyed">Samoyed</option>
<option value="Schipperke">Schipperke</option>
<option value="Scottish Deerhound">Scottish Deerhound</option>
<option value="Scottish Terrier">Scottish Terrier</option>
<option value="Shetland Sheepdog">Shetland Sheepdog</option>
<option value="Shiba Inu">Shiba Inu</option>
<option value="Shih Tzu">Shih Tzu</option>
<option value="Shikoku">Shikoku</option>
<option value="Siberian Husky">Siberian Husky</option>
<option value="Siberian Laika">Siberian Laika</option>
<option value="Sloughi">Sloughi</option>
<option value="Smooth Collie">Smooth Collie</option>
<option value="Smooth Fox Terrier">Smooth Fox Terrier</option>
<option value="Soft Coated Wheaten Terrier">Soft Coated Wheaten Terrier</option>
<option value="Staffordshire Bull Terrier">Staffordshire Bull Terrier</option>
<option value="Sussex Spaniel">Sussex Spaniel</option>
<option value="Swedish Vallhund">Swedish Vallhund</option>
<option value="Taiwan Dog">Taiwan Dog</option>
<option value="Tibetan Spaniel">Tibetan Spaniel</option>
<option value="Toy Fox Terrier">Toy Fox Terrier</option>
<option value="Toy Poodle">Toy Poodle</option>
<option value="Toy Spaniel">Toy Spaniel</option>
<option value="Welsh Springer Spaniel">Welsh Springer Spaniel</option>
<option value="Welsh Terrier">Welsh Terrier</option>
<option value="Yorkshire Terrier">Yorkshire Terrier</option>

</select><p>
	
	<input type="submit" name="dogsearch" value="Search">
        </form>

</td></table>

HERE;

?>

NOTE: I didn't include the 'for sale?' form in this code.

This is this part of code that I don't know how to incorparate the 2 last feilds in.

$result = mysql_query("SELECT dogID, name FROM dog WHERE name='$dogname' OR dogID='$dogid'");

If you guys need anymore information, just let me know.

I greatly appreciate any help =)





#2 markbett

markbett
  • Members
  • PipPipPip
  • Advanced Member
  • 133 posts

Posted 23 September 2006 - 01:02 AM

well you can look to see which fields are set and if the user hasnt input any data into a specific textbox/field then you ignore it in your query....

#3 pocobueno1388

pocobueno1388
  • Members
  • PipPipPip
  • Advanced Member
  • 3,369 posts
  • LocationPalm Beach, Florida

Posted 23 September 2006 - 01:04 AM

That is my problem...I don't know how to ignore empty fields.

Would I just do an if statement?

if ($name){
       $result = mysql_query("SELECT dogID, name FROM dog WHERE name='$dogname'");
}

Then just do that for each form? That doesn't seem like it would work to me...I don't know though.

#4 michaellunsford

michaellunsford
  • Members
  • PipPipPip
  • Advanced Member
  • 1,023 posts
  • LocationLouisiana, USA

Posted 23 September 2006 - 01:17 AM

is_set($varname) will tell you if a variable exists. sometimes simply saying if($varname) or shortcutting ($varname? will return false if the variable doesn't exist.

#5 pocobueno1388

pocobueno1388
  • Members
  • PipPipPip
  • Advanced Member
  • 3,369 posts
  • LocationPalm Beach, Florida

Posted 23 September 2006 - 01:19 AM

So it would be like this?

if (is_set($name)){
       $result = mysql_query("SELECT dogID, name FROM dog WHERE name='$dogname'");
}

But one for each form...?

#6 michaellunsford

michaellunsford
  • Members
  • PipPipPip
  • Advanced Member
  • 1,023 posts
  • LocationLouisiana, USA

Posted 23 September 2006 - 01:33 AM

You'd lose data if they filled in more than one field. Just build a smarter query. Here's a sloppy example I threw together:

if($dogname) $my_array[$i++]=" `dogname` = '$dogname'";
if($dogid) $my_array[$i++]=" `dogid` = '$dogid'";
if($breed) $my_array[$i++]=" `breed ` = '$breed'";
// etc //
reset ($my_array);
$query = "SELECT `dogID`, `name` FROM `dog`";
if($my_array) $query.=" WHERE ";
do {
    $query.=current($my_array)." AND";
} while(next($my_array));
$query=substr($query,0,-4); //removes the trailing AND from the end
$result = mysql_query($query);


#7 pocobueno1388

pocobueno1388
  • Members
  • PipPipPip
  • Advanced Member
  • 3,369 posts
  • LocationPalm Beach, Florida

Posted 23 September 2006 - 01:43 AM

Yikes, a search is obvioulsy to advanced for me. I will have to do some research on it I guess. Thanks for the help anyways.

#8 michaellunsford

michaellunsford
  • Members
  • PipPipPip
  • Advanced Member
  • 1,023 posts
  • LocationLouisiana, USA

Posted 23 September 2006 - 01:51 AM

Sorry, I tend to overcomplicate things... lets simplify:

$query = "SELECT `dogID`, `name` FROM `dog` WHERE 1";
if($dogname) $query.=" AND `dogname` = '$dogname'";
if($dogid) $query.=" AND `dogid` = '$dogid'";
if($breed) $query.=" AND `breed ` = '$breed'";
$result = mysql_query($query);


EDIT: forgot the dots, Dooh!

#9 willfitch

willfitch
  • Members
  • PipPipPip
  • Advanced Member
  • 109 posts
  • LocationNew Hope, PA

Posted 23 September 2006 - 01:57 AM

You could also consider doing a full-text index on your fields being searched and query by relevance like so:

<?php
$query = "SELECT MATCH(name,breed) AGAINST ('$single_key_word') AS relevance, name, breed
FROM dog 
HAVING relevance > 0
ORDER BY relevance DESC";
?>

This would be a true search engine and bring back results ordered by their relevance.  Remember, the fields (name,breed) will have to have the FULLTEXT index assigned.
Zend Certified Engineer (ZEND001989)
www.willfitch.com

#10 pocobueno1388

pocobueno1388
  • Members
  • PipPipPip
  • Advanced Member
  • 3,369 posts
  • LocationPalm Beach, Florida

Posted 23 September 2006 - 03:50 AM

Much much simpler to understand, lol.

Here is my code now, I am getting an error with my mysql_fetch_assoc(). Here is the error:

Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/colin/public_html/dogsearch.php on line 16

Here is the code that goes along with that error:

$dogname = $_POST['dogname'];
$dogid = $_POST['dogid'];
$breed = $_POST['breed'];

$query = "SELECT `dogID`, `name` FROM `dog` WHERE 1";
if($dogname) $query.=" AND `dogname` = '$dogname'";
if($dogid) $query.=" AND `dogid` = '$dogid'";
if($breed) $query.=" AND `breed ` = '$breed'";
$result = mysql_query($query);

$row = mysql_fetch_assoc($result); // NOT VALID...?

Here is the entire code:

<?php
include 'header.php';

if ($_POST['dogsearch']) {

$dogname = $_POST['dogname'];
$dogid = $_POST['dogid'];
$breed = $_POST['breed'];

$query = "SELECT `dogID`, `name` FROM `dog` WHERE 1";
if($dogname) $query.=" AND `dogname` = '$dogname'";
if($dogid) $query.=" AND `dogid` = '$dogid'";
if($breed) $query.=" AND `breed ` = '$breed'";
$result = mysql_query($query);

$row = mysql_fetch_assoc($result);




$sql_name_check = mysql_query("SELECT dogID, name FROM dog WHERE name='$dogname' OR dogID='$dogid'");

$name_check = mysql_num_rows($sql_name_check);




if($name_check < 0){

     print "<table width='40%' bgcolor='49614A'><td align='center' bgcolor='788D7A'><b>No such dog!</b></td></table></b>";
     
} else {


print<<<HERE

	<table width="90%" align="left">
	<td>

	<h2>Search Results:</h2><p>


	<a href="dog.php?id=$row[dogID]">$row[name] ($row[dogID])</a>

	</td></table>

HERE;

}
exit;
 }

print<<<HERE

	<table width="90%" align="left">
	<td>

	<h3>Search Dogs</h3>

	<form action="dogsearch.php?action=search" method="POST">
	Name:<br>
	<input type="text" name="dogname"><p>
	ID:<br>
	<input type="text" name="dogid" size=8><p>
<select name="breed"><option value="">No Breed</option>
<option value="Afghan Hound">Afghan Hound</option>
<option value="Airedale Terrier">Airedale Terrier</option>
<option value="Alaskan Husky">Alaskan Husky</option>
<option value="Alaskan Malamute">Alaskan Malamute</option>
<option value="American Bulldog">American Bulldog</option>
<option value="American Eskimo Dog">American Eskimo Dog</option>
<option value="American Indian Dog">American Indian Dog</option>
<option value="American Pitbull Terrier">American Pitbull Terrier</option>
<option value="American White Shepherd">American White Shepherd</option>
<option value="Anatolian Shepherd">Anatolian Shepherd</option>
<option value="Australian Cattle Dog">Australian Cattle Dog</option>
<option value="Australian Koolie">Australian Koolie</option>
<option value="Australian Shepherd">Australian Shepherd</option>
<option value="Basenji">Basenji</option>
<option value="Basset Hound">Basset Hound</option>
<option value="Beagle">Beagle</option>
<option value="Bearded Collie">Bearded Collie</option>
<option value="Bedlington Terrier">Bedlington Terrier</option>
<option value="Belgian Malinois">Belgian Malinois</option>
<option value="Belgian Sheepdog">Belgian Sheepdog</option>
<option value="Belgian Tervuren">Belgian Tervuren</option>
<option value="Bernese Mountain Dog">Bernese Mountain Dog</option>
<option value="Bloodhound">Bloodhound</option>
<option value="Border Collie">Border Collie</option>
<option value="Border Terrier">Border Terrier</option>
<option value="Borzoi">Borzoi</option>
<option value="Boston Terrier">Boston Terrier</option>
<option value="Bouvier des Flandres">Bouvier des Flandres</option>
<option value="Boxer">Boxer</option>
<option value="Boykin Spaniel">Boykin Spaniel</option>
<option value="Briard">Briard</option>
<option value="Brittany Spaniel">Brittany Spaniel</option>
<option value="Brussels Griffon">Brussels Griffon</option>
<option value="Bull Terrier">Bull Terrier</option>
<option value="Bulldog">Bulldog</option>
<option value="Bullmastiff">Bullmastiff</option>
<option value="Cairn Terrier">Cairn Terrier</option>
<option value="Canaan Dog">Canaan Dog</option>
<option value="Cardigan Welsh Corgi">Cardigan Welsh Corgi</option>
<option value="Caucasian Ovtcharka">Caucasian Ovtcharka</option>
<option value="Chart Polski">Chart Polski</option>
<option value="Chesapeake Bay Retriever">Chesapeake Bay Retriever</option>
<option value="Chihuahua">Chihuahua</option>
<option value="Chinese Crested">Chinese Crested</option>
<option value="Chinese Shar-Pei">Chinese Shar-Pei</option>
<option value="Chinook">Chinook</option>
<option value="Chow-chow">Chow-chow</option>
<option value="Clumber Spaniel">Clumber Spaniel</option>
<option value="Cocker Spaniel">Cocker Spaniel</option>
<option value="Curly-Coated Retriever">Curly-Coated Retriever</option>
<option value="Dachshund">Dachshund</option>
<option value="Dalmatian">Dalmatian</option>
<option value="Doberman Pinscher">Doberman Pinscher</option>
<option value="Dutch Shepherd">Dutch Shepherd</option>
<option value="English Foxhound">English Foxhound</option>
<option value="English Mastiff">English Mastiff</option>
<option value="English Setter">English Setter</option>
<option value="English Shepherd">English Shepherd</option>
<option value="English Springer Spaniel">English SpringerSpaniel</option>
<option value="Eurasier">Eurasier</option>
<option value="Flat-Coated Retriever">Flat-Coated Retriever</option>
<option value="French Bulldog">French Bulldog</option>
<option value="German Pinscher">German Pinscher</option>
<option value="German Shepherd">German Shepherd</option>
<option value="German Shorthaired Pointer">German Shorthaired Pointer</option>
<option value="German Wirehaired Pointer">German Wirehaired Pointer</option>
<option value="Giant Schnauzer">Giant Schnauzer</option>
<option value="Golden Retriever">Golden Retriever</option>
<option value="Gordon Setter">Gordon Setter</option>
<option value="Great Dane">Great Dane</option>
<option value="Greater Swiss Mountain Dog">Greater Swiss Mountain Dog</option>
<option value="Greyhound">Greyhound</option>
<option value="Harrier">Harrier</option>
<option value="Havanese">Havanese</option>
<option value="Hovawart">Hovawart</option>
<option value="Irish Setter">Irish Setter</option>
<option value="Irish Terrier">Irish Terrier</option>
<option value="Irish Wolfhound">Irish Wolfhound</option>
<option value="Italian Greyhound">Italian Greyhound</option>
<option value="Jack Russel Terrier">Jack Russel Terrier</option>
<option value="Japanese Chin">Japanese Chin</option>
<option value="Kerry Blue Terrier">Kerry Blue Terrier</option>
<option value="Komondor">Komondor</option>
<option value="Labrador Retriever">Labrador Retriever</option>
<option value="Long-haired Collie">Long-haired Collie</option>
<option value="Maltese">Maltese</option>
<option value="Manchester Terrier">Manchester Terrier</option>
<option value="Maremma Sheepdog">Maremma Sheepdog</option>
<option value="Mastiff">Mastiff</option>
<option value="Miniature Australian Shepherd">Miniature Australian Shepherd</option>
<option value="Miniature Dachshund">Miniature Dachshund</option>
<option value="Miniature Pinscher">Miniature Pinscher</option>
<option value="Miniature Schnauzer">Miniature Schnauzer</option>
<option value="Old English Sheepdog">Old English Sheepdog</option>
<option value="Otterhound">Otterhound</option>
<option value="Papillon">Papillon</option>
<option value="Pekingese">Pekingese</option>
<option value="Pembroke Welsh Corgi">Pembroke Welsh Corgi</option>
<option value="Plott">Plott</option>
<option value="Pointer">Pointer</option>
<option value="Pomeranian">Pomeranian</option>
<option value="Poodle">Poodle</option>
<option value="Pug">Pug</option>
<option value="Rottweiler">Rottweiler</option>
<option value="Saarloos Wolfhound">Saarloos Wolfhound</option>
<option value="Saint Bernard">Saint Bernard</option>
<option value="Saluki">Saluki</option>
<option value="Samoyed">Samoyed</option>
<option value="Schipperke">Schipperke</option>
<option value="Scottish Deerhound">Scottish Deerhound</option>
<option value="Scottish Terrier">Scottish Terrier</option>
<option value="Shetland Sheepdog">Shetland Sheepdog</option>
<option value="Shiba Inu">Shiba Inu</option>
<option value="Shih Tzu">Shih Tzu</option>
<option value="Shikoku">Shikoku</option>
<option value="Siberian Husky">Siberian Husky</option>
<option value="Siberian Laika">Siberian Laika</option>
<option value="Sloughi">Sloughi</option>
<option value="Smooth Collie">Smooth Collie</option>
<option value="Smooth Fox Terrier">Smooth Fox Terrier</option>
<option value="Soft Coated Wheaten Terrier">Soft Coated Wheaten Terrier</option>
<option value="Staffordshire Bull Terrier">Staffordshire Bull Terrier</option>
<option value="Sussex Spaniel">Sussex Spaniel</option>
<option value="Swedish Vallhund">Swedish Vallhund</option>
<option value="Taiwan Dog">Taiwan Dog</option>
<option value="Tibetan Spaniel">Tibetan Spaniel</option>
<option value="Toy Fox Terrier">Toy Fox Terrier</option>
<option value="Toy Poodle">Toy Poodle</option>
<option value="Toy Spaniel">Toy Spaniel</option>
<option value="Welsh Springer Spaniel">Welsh Springer Spaniel</option>
<option value="Welsh Terrier">Welsh Terrier</option>
<option value="Yorkshire Terrier">Yorkshire Terrier</option>

</select><p>
	
	<input type="submit" name="dogsearch" value="Search">

	</form>
	</td></table>
HERE;

?>


The only thing that will work is if I type in a dog's ID in the ID field of the form and press 'Search'. Everything else returns the error.

#11 michaellunsford

michaellunsford
  • Members
  • PipPipPip
  • Advanced Member
  • 1,023 posts
  • LocationLouisiana, USA

Posted 23 September 2006 - 03:55 AM

right after
$result=mysql_query($query);
add the following:
if(mysql_error()) echo mysql_error()."<br><br>\n\n".$query;

that will give you the mysql error message and the offending query.

#12 pocobueno1388

pocobueno1388
  • Members
  • PipPipPip
  • Advanced Member
  • 3,369 posts
  • LocationPalm Beach, Florida

Posted 23 September 2006 - 04:24 AM

Duh, I should have known that. Everything works beautifully. Thank you for all the time you put into helping me =) I really appreciate it.

#13 michaellunsford

michaellunsford
  • Members
  • PipPipPip
  • Advanced Member
  • 1,023 posts
  • LocationLouisiana, USA

Posted 23 September 2006 - 05:24 PM

<?php
$query = "SELECT MATCH(name,breed) AGAINST ('$single_key_word') AS relevance, name, breed
FROM dog 
HAVING relevance > 0
ORDER BY relevance DESC";
?>


I haven't seen this mysql query method before -- is it possible to use it with multiple_key_words?

#14 pocobueno1388

pocobueno1388
  • Members
  • PipPipPip
  • Advanced Member
  • 3,369 posts
  • LocationPalm Beach, Florida

Posted 24 September 2006 - 04:40 AM

I'm not sure, I used your first suggestion =/ I am not familiar with that method at all.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users