close ad
Help us test the new Databridge BETA with MySQLi support
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

converting search

Thread began 4/23/2018 10:19 pm by Jamie | Last modified 4/25/2018 12:46 pm by Jamie | 41 views | 3 replies

Jamie

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

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...