Jump to content

Full Text Search


hasek522

Recommended Posts

I am trying to use a FULLTEXT sql search but am encountering a sql error I cant figure out.

Here is the error:

 

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /nfs/c03/h01/mnt/48237/domains/hairneedhelp.net/html/search.php on line 15

 

Here is the code:

 

$search = $_POST['search'];

$search = '%' . $search . '%';

$db = mysql_connect($dbhost, $dbuser, $dbpassword);

mysql_select_db($dbdatabase, $db);

$search = mysql_real_escape_string($search);

$sql = "SELECT * FROM stylists WHERE MATCH(firstname, lastname, city, salon, specialty) AGAINST ('" . $search . "');";

$query = mysql_query($sql);

while($row = mysql_fetch_array($query))

Link to comment
https://forums.phpfreaks.com/topic/119315-full-text-search/
Share on other sites

Example of a better method?

 

A proper error handling class. die()'ing is horrible. I'd rather purge all object buffers and output a decent looking error page, then die() silently.

 

This allows you to hide details ( revealing potential database structure, ect ) in a production environment with a debug constant set to false, and allows you to see them while programming, or, debugging.

Link to comment
https://forums.phpfreaks.com/topic/119315-full-text-search/#findComment-614651
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.