S
Sean G
Guest
Hey!
Ok, my website is basically just a front-end for a large MySQL database, so the search pages are extremely important. However, i'm quite new to MySQL, so i'm not entirely sure how to go about this.
At the moment, my search will look through the table for the EXACT term entered. I need a search that doesn't care about the case of the letters, and will search for a result that contains every word entered, not the whole phrase. I have included the basic idea of my current search at the bottom.
Can anyone help me...? This is really frustrating me...
$search=$_POST["search"];
$result = mysql_query("SELECT * FROM table WHERE field LIKE '%$search%'");
while($r=mysql_fetch_array($result))
{
display results code
}
Thank you jon... i'll take a look at that in a second.
That's something else i meant to add (think i missed out another bit of info too, but can't remember what...)... I needed a way of striping the query of code... I've seen a few vunrabilities with MySQL and PHP things on websites. My email form is nicely protected from this. Thanks for that.
Thank you for the restricted user suggestion. I think i've done that on one of my other sites actually. Unfortunately my current host/plan only allows one user...
@jon c
it is throwing up an error:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/www/recipefinder.awardspace.com/newsearch.php on line 43
lines 42 and 43 being:
$result = mysql_query("SELECT * FROM recipes " . mysql_real_escape_string($words_query));
while($r=mysql_fetch_array($result))
Ok, my website is basically just a front-end for a large MySQL database, so the search pages are extremely important. However, i'm quite new to MySQL, so i'm not entirely sure how to go about this.
At the moment, my search will look through the table for the EXACT term entered. I need a search that doesn't care about the case of the letters, and will search for a result that contains every word entered, not the whole phrase. I have included the basic idea of my current search at the bottom.
Can anyone help me...? This is really frustrating me...
$search=$_POST["search"];
$result = mysql_query("SELECT * FROM table WHERE field LIKE '%$search%'");
while($r=mysql_fetch_array($result))
{
display results code
}
Thank you jon... i'll take a look at that in a second.
That's something else i meant to add (think i missed out another bit of info too, but can't remember what...)... I needed a way of striping the query of code... I've seen a few vunrabilities with MySQL and PHP things on websites. My email form is nicely protected from this. Thanks for that.
Thank you for the restricted user suggestion. I think i've done that on one of my other sites actually. Unfortunately my current host/plan only allows one user...
@jon c
it is throwing up an error:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/www/recipefinder.awardspace.com/newsearch.php on line 43
lines 42 and 43 being:
$result = mysql_query("SELECT * FROM recipes " . mysql_real_escape_string($words_query));
while($r=mysql_fetch_array($result))