Searching multiple fields


#1

Hi All,

I am trying to search multiple fields using a variable next string. When i run the section of code below i get the following message;

Warning: sprintf(): Too few arguments in /home/sites/botanicalsearch.com/public_html/results02.php on line 17
You have an error in your SQL syntax near ‘LIMIT 0, 10’ at line 1

Here is the section of code. Any help would be greatly received.

mysql_select_db($database_Botanical, $Botanical);
$query_rs_results = sprintf(“SELECT * FROM botanical WHERE ExtractName LIKE ‘%%%s%%’ OR OtherNames LIKE ‘%%%s%%’ AND Alive ='1’ORDER BY ExtractName ASC”, $varExtract_rs_results);
$query_limit_rs_results = sprintf("%s LIMIT %d, %d", $query_rs_results, $startRow_rs_results, $maxRows_rs_results);
$rs_results = mysql_query($query_limit_rs_results, $Botanical) or die(mysql_error());
$row_rs_results = mysql_fetch_assoc($rs_results);


#2

sprintf(“SELECT * FROM botanical WHERE ExtractName LIKE ‘%%%s%%’ OR OtherNames LIKE ‘%%%s%%’ AND Alive ='1’ORDER BY ExtractName ASC”, $varExtract_rs_results);

You have 2 variable placeholders and only 1 variable. If you want the same variable in both places tell it:
, $varExtract_rs_results, $varExtract_rs_results);