converting search
Hey Ray
Just tried converting a search from
<?php
//WA Database Search (Copyright 2005, WebAssist.com)
//Recordset: WADAproducts;
//Searchpage: test.htm;
//Form: SearchForm;
$WADbSearch1_DefaultWhere = "";
if (!session_id()) session_start();
if ((isset($_POST["WADbSearch1"])) && ($_POST["WADbSearch1"] != "")) {
$WADbSearch1 = new FilterDef;
$WADbSearch1->initializeQueryBuilder("MYSQL","1");
//keyword array declarations
$KeyArr1 = array("ProductID", "ProductSKU", "ProductName", "ProductPrice", "ProductLongDesc", "CategoryName", "ManufacturerName");
//comparison list additions
$WADbSearch1->keywordComparison($KeyArr1,"".((isset($_POST["SearchContent"]))?$_POST["SearchContent"]:"") ."","AND","Includes",",%20","%20","%22","%22",0);
//save the query in a session variable
if (1 == 1) {
$_SESSION["WADbSearch1_product_results"]=$WADbSearch1->whereClause;
}
}
else {
$WADbSearch1 = new FilterDef;
$WADbSearch1->initializeQueryBuilder("MYSQL","1");
//get the filter definition from a session variable
if (1 == 1) {
if (isset($_SESSION["WADbSearch1_product_results"]) && $_SESSION["WADbSearch1_product_results"] != "") {
$WADbSearch1->whereClause = $_SESSION["WADbSearch1_product_results"];
}
else {
$WADbSearch1->whereClause = $WADbSearch1_DefaultWhere;
}
}
else {
$WADbSearch1->whereClause = $WADbSearch1_DefaultWhere;
}
}
$WADbSearch1->whereClause = str_replace("\\''", "''", $WADbSearch1->whereClause);
$WADbSearch1whereClause = '';
?>
to
<?php
$searchWADAproducts_1 = new WA_MySQLi_Search("WADAproducts","");
if ((isset($_POST["WADbSearch1"])) && ($_POST["WADbSearch1"] != "")) {
$searchWADAproducts_1->clearSearch();
$searchWADAproducts_1->setSearch(array("type"=>"Key", "comparison"=>"Includes", "join"=>"AND", "and"=>", ", "or"=>" ", "start_encap"=>"\"", "end_encap"=>"\""), array("ProductID", "ProductSKU", "ProductName", "ProductPrice", "ProductLongDesc", "CategoryName", "ManufacturerName"), "s", "".((isset($_POST["SearchContent"]))?$_POST["SearchContent"]:"") ."");
}
?>
and when you go to the results page the error is shown:
[codeSELECT products.*, productcategories.*, GROUP_CONCAT(CategoryName SEPARATOR ', ') AS AllCategories FROM products LEFT JOIN productcategoryjoin ON JoinProductID = ProductID LEFT JOIN productcategories ON JoinCategoryID = productcategories.CategoryID WHERE ((`ProductID` Includes ?) OR (`ProductSKU` Includes ?) OR (`ProductName` Includes ?) OR (`ProductPrice` Includes ?) OR (`ProductLongDesc` Includes ?) OR (`CategoryName` Includes ?) OR (`ManufacturerName` Includes ?)) GROUP BY ProductID
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Includes ?) OR (`ProductSKU` Includes ?) OR (`ProductName` Includes ?) OR (`Prod' at line 1[/code]
I have also tried removing the search code and doing it from scratch and using
<?php
$searchWADAproducts_1 = new WA_MySQLi_Search("WADAproducts","");
if (isset($_POST["WADbSearch1"]) || isset($_POST["WADbSearch1_x"])) {
$searchWADAproducts_1->clearSearch();
$searchWADAproducts_1->setSearch(array("type"=>"Key", "comparison"=>"Includes", "join"=>"AND", "and"=>", ", "or"=>" ", "start_encap"=>"\"", "end_encap"=>"\""), array("ProductSKU", "ProductName", "ProductLongDesc"), "s", "".(((isset($_POST["SearchContent"]))?$_POST["SearchContent"]:"")) ."");
}
?>
and that ends up with an error
SELECT products.*, productcategories.*, GROUP_CONCAT(CategoryName SEPARATOR ', ') AS AllCategories FROM products LEFT JOIN productcategoryjoin ON JoinProductID = ProductID LEFT JOIN productcategories ON JoinCategoryID = productcategories.CategoryID WHERE ((`ProductID` Includes ?) OR (`ProductSKU` Includes ?) OR (`ProductName` Includes ?) OR (`ProductPrice` Includes ?) OR (`ProductLongDesc` Includes ?) OR (`CategoryName` Includes ?) OR (`ManufacturerName` Includes ?)) GROUP BY ProductID
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Includes ?) OR (`ProductSKU` Includes ?) OR (`ProductName` Includes ?) OR (`Prod' at line 1