close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

Error with WebAssist Search function

Thread began 7/17/2018 1:52 pm by sandy170299 | Last modified 7/18/2018 8:23 am by sandy170299 | 834 views | 1 replies

sandy170299

Error with WebAssist Search function

I have a form with 2 search fields on it, and I would like this form to filter a recordset on the page. This is my code:

<?php require_once('../Connections/etrends.php'); ?>
<?php require_once("../webassist/database_management/wada_search.php"); ?>
<?php
//WA Database Search (Copyright 2005, WebAssist.com)
//Recordset: getPO;
//Searchpage: ;
//Form: ;
$WADbSearch1_DefaultWhere = "0=0";
if (!session_id()) session_start();
if (isset($_POST["submit"]) || isset($_POST["submit_x"])) {
$WADbSearch1 = new FilterDef;
$WADbSearch1->initializeQueryBuilder("MYSQL","1");
//keyword array declarations

//comparison list additions
$WADbSearch1->addComparison("PlaceID","".((isset($_POST["PlaceID"]))?$_POST["PlaceID"]:"") ."","AND","=",1);
$WADbSearch1->addComparison("OfficeID","".((isset($_POST["OfficeID"]))?$_POST["OfficeID"]:"") ."","AND","=",1);

//save the query in a session variable
if (1 == 1) {
$_SESSION["WADbSearch1_Psearch"]=$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_Psearch"]) && $_SESSION["WADbSearch1_Psearch"] != "") {
$WADbSearch1->whereClause = $_SESSION["WADbSearch1_Psearch"];
}
else {
$WADbSearch1->whereClause = $WADbSearch1_DefaultWhere;
}
}
else {
$WADbSearch1->whereClause = $WADbSearch1_DefaultWhere;
}
}
$WADbSearch1->whereClause = str_replace("\\''", "''", $WADbSearch1->whereClause);
$WADbSearch1whereClause = '';
?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}

$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}

mysql_select_db($database_etrends, $etrends);
$query_getPlaces = "SELECT places.ID AS PlaceID, places.Name AS PlaceName FROM places";
$getPlaces = mysql_query($query_getPlaces, $etrends) or die(mysql_error());
$row_getPlaces = mysql_fetch_assoc($getPlaces);
$totalRows_getPlaces = mysql_num_rows($getPlaces);

mysql_select_db($database_etrends, $etrends);
$query_getOffices = "SELECT offices.ID AS OfficeID, offices.Office FROM offices ORDER BY Office ASC";
$getOffices = mysql_query($query_getOffices, $etrends) or die(mysql_error());
$row_getOffices = mysql_fetch_assoc($getOffices);
$totalRows_getOffices = mysql_num_rows($getOffices);

mysql_select_db($database_etrends, $etrends);
$query_getPO = "SELECT places.ID AS PlaceID, places.Name AS PlaceName, offices.ID AS OfficeID, offices.Office FROM places INNER JOIN offices ON places.ID = offices.PlaceID";
setQueryBuilderSource($query_getPO,$WADbSearch1,false);
$getPO = mysql_query($query_getPO, $etrends) or die(mysql_error());
$row_getPO = mysql_fetch_assoc($getPO);
$totalRows_getPO = mysql_num_rows($getPO);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
body,td,th {
font-family: Arial, Helvetica, sans-serif;
}
body {
margin-left: 250px;
}
</style>
</head>

<body>
<h2>Advanced Search by Places, Office, and Year</h2>
<form id="form1" name="form1" method="post" action="P-search.php">
<p>City:
<select name="PlaceID" id="PlaceID">
<?php
do {
?>
<option value="<?php echo $row_getPlaces['PlaceID']?>"><?php echo $row_getPlaces['PlaceName']?></option>
<?php
} while ($row_getPlaces = mysql_fetch_assoc($getPlaces));
$rows = mysql_num_rows($getPlaces);
if($rows > 0) {
mysql_data_seek($getPlaces, 0);
$row_getPlaces = mysql_fetch_assoc($getPlaces);
}
?>
</select>
</p>
<p>Office:
<select name="OfficeID" id="OfficeID">
<?php
do {
?>
<option value="<?php echo $row_getOffices['OfficeID']?>"><?php echo $row_getOffices['Office']?></option>
<?php
} while ($row_getOffices = mysql_fetch_assoc($getOffices));
$rows = mysql_num_rows($getOffices);
if($rows > 0) {
mysql_data_seek($getOffices, 0);
$row_getOffices = mysql_fetch_assoc($getOffices);
}
?>
</select>
</p>
<p>
<input type="submit" name="submit" id="submit" value="Search" />
</p>
<table cellpadding="2" cellspacing="0" border="0">
<tr>
<td align="center"><input type="hidden" name="WADbSearch1" value="Submit" /></td>
</tr>
</table>
</form>

</body>
</html>

When I preview the site in a browser, I get the following error: Unknown column 'OfficeID' in 'where clause'

I've included this field in my search criteria, and I can't see why it's not working. Also, when I try to edit the server behavior, nothing shows up. I will attach a screen print. I'm using Data Bridge 2.0.0. and I believe this is the Beta version, but I'm not sure how to tell.

Thank you.

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...