close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Using DataAssist Search Shows all records

Thread began 8/24/2010 6:26 am by JBWebWorks | Last modified 8/25/2010 10:58 am by Jason Byrnes | 3448 views | 12 replies |

JBWebWorks

Using DataAssist Search Shows all records

When i access the results page directly or when i click the submit button on the search page without any search input, the results page shows all records and i want it to show none.
Using this in the code
$WADbSearch1_DefaultWhere = "0<>0";

produces this error
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 '0<>0 ORDER BY unclassified.ad_post_date DESC' at line 1

thanks for your help,
Jim Balthrop

Sign in to reply to this post

Jason ByrnesWebAssist

for mySQL the correct default where syntax is 0 != 0

$WADbSearch1_DefaultWhere = "0 != 0";

Sign in to reply to this post

JBWebWorks

Thanks Jason

tried that

$WADbSearch1_DefaultWhere = "0 != 0";

and still got error message?

Sign in to reply to this post

Jason ByrnesWebAssist

please post the exact error message and a copy of your page.

Sign in to reply to this post

JBWebWorks

Error Message----
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 '0 != 0 ORDER BY unclassified.ad_post_date DESC' at line 1

Page Code----
<?php require_once('Connections/connauto.php'); ?>
<?php require_once('Connections/connauto.php');?>
<?php require_once( "WA_SecurityAssist/Helper_PHP.php" ); ?>
<?php
if(isset($_POST["login1"])){
$WA_Auth_Parameter = array(
"connection" => $connauto,
"database" => $database_connauto,
"tableName" => "client_info",
"columns" => explode($WA_Auth_Separator,"client_email".$WA_Auth_Separator."client_pw".$WA_Auth_Separator."client_verified"),
"columnValues" => explode($WA_Auth_Separator,"".((isset($_POST["user_name"]))?$_POST["user_name"]:"") ."".$WA_Auth_Separator."".((isset($_POST["password"]))?$_POST["password"]:"") ."".$WA_Auth_Separator."yes"),
"columnTypes" => explode($WA_Auth_Separator,"text".$WA_Auth_Separator."text".$WA_Auth_Separator."text"),
"sessionColumns" => explode($WA_Auth_Separator,"client_ID"),
"sessionNames" => explode($WA_Auth_Separator,"client_ID"),
"successRedirect" => "my_account1.php",
"failRedirect" => "?failed=true",
"gotoPreviousURL" => TRUE,
"keepQueryString" => TRUE
);

WA_AuthenticateUser($WA_Auth_Parameter);
}
?>
<?php
//WA Database Search Include
require_once("WADbSearch/HelperPHP.php");
?>
<?php
//WA Database Search (Copyright 2005, WebAssist.com)
//Recordset: rs_unclassified;
//Searchpage: ;
//Form: ;
$WADbSearch1_DefaultWhere = "0 != 0";
if (!session_id()) session_start();
if ((((isset($_POST["search1"]))?$_POST["search1"]:"") != "")) {
$WADbSearch1 = new FilterDef;
$WADbSearch1->initializeQueryBuilder("MYSQL","1");
//keyword array declarations

//comparison list additions
$WADbSearch1->addComparison("ad_city_state","".((isset($_POST["search_location"]))?$_POST["search_location"]:"") ."","AND","Includes",0);
$WADbSearch1->addComparison("ad_header","".((isset($_POST["search_header"]))?$_POST["search_header"]:"") ."","AND","Includes",0);
$WADbSearch1->addComparison("ad_title","".((isset($_POST["search_title"]))?$_POST["search_title"]:"") ."","AND","Includes",0);
$WADbSearch1->addComparison("ad_price","".((isset($_POST["price_low"]))?$_POST["price_low"]:"") ."","AND",">=",1);
$WADbSearch1->addComparison("ad_price","".((isset($_POST["price_high"]))?$_POST["price_high"]:"") ."","AND","<=",1);

//save the query in a session variable
if (1 == 1) {
$_SESSION["WADbSearch1_unclassified_display1"]=$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_unclassified_display1"]) && $_SESSION["WADbSearch1_unclassified_display1"] != "") {
$WADbSearch1->whereClause = $_SESSION["WADbSearch1_unclassified_display1"];
}
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_connauto, $connauto);
$query_rs_unclassified = "SELECT * FROM unclassified WHERE unclassified.ad_verify = 'Y' ORDER BY unclassified.ad_post_date DESC";
setQueryBuilderSource($query_rs_unclassified,$WADbSearch1,false);
$rs_unclassified = mysql_query($query_rs_unclassified, $connauto) or die(mysql_error());
$row_rs_unclassified = mysql_fetch_assoc($rs_unclassified);
$totalRows_rs_unclassified = mysql_num_rows($rs_unclassified);

function highlightResults($dataValue, $searchString) {
return (preg_replace("/$searchString/i", '<span style="color:red;">'.strtoupper($searchString).'</span>', $dataValue));
}
?>
</head>

<body>

<div id="outerWrapper">
<div id="header">
<table width="100%"id="head_table">
<tr>
<td width="27%">&nbsp;&nbsp;&nbsp;&nbsp; <div style=" padding-top:15px."><br />
<br />
<br />
<br />
<img src="Logo/LaDollarSaverLogo_002.png" alt="LA Dollar Saver" width="234" height="51" /></div></td>
<td valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="4%">&nbsp;</td>
<td><div id="logohearerdive">Introducing the Web’s First “Unclassified” <br />
<br />
Local Area Shopper. </div></td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><br><br><br></td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><div style="line-height:22px;">Find what you want here...........</div></td>
<td>&nbsp;</td>
</tr>

</table></td>
<td width="35%" valign="top"><table width="400" cellpadding="5">
<tr>
<td width="40%">Log-In Here<br />
<a href="email_pw.php" target="_blank"><span class="style2">Forgot Login</span></a>&nbsp;<span class="style2">|</span>&nbsp;<a href="anfregister.php"><span class="style2">To Register</span></a> <span class="style2">|</span>&nbsp;<span class="style2"><a href="my_account1.php">MyAccount</a></span></td>
<td width="30%">
<input name="logout1" type="submit" class="stylelogin" id="logout1" style="width: 60px;" onclick="MM_goToURL('plugins/parent','LogOut.php');return document.MM_returnValue" value="LogOut" />

</tr>
</table>
<table width="100%" cellpadding="5">
<tr>
<td><span class="style3"><?php echo(isset($_GET['failed']))? "Login is not verified. Please try again":""; ?>
</span>




<form id="login" method="post">
<table width="90%" cellpadding="5">
<tr>
<td align="right"><strong><span class="style2">Email Address:</span></strong></td>
<td><input name="user_name" type="text" id="user_name" maxlength="75" /></td>
</tr>
<tr>
<td align="right"><strong><span class="style2">Password:</span></strong></td>
<td><input type="password" name="password" id="password" />
<br /></td>
</tr>
<tr>
<td align="right">&nbsp;</td>
<td><input type="submit" name="login1" id="login1" value="LogIn" /></td>
</tr>
<tr>
<td align="right"></td>
<td></td>
</tr>
</table>
</form>
</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
<div id="topNavigation">
<?php include("anf_incluse_nav.php") ?>
</div>
<div id="contentWrapper">
<div id="leftColumn1">
<h1>Unclassified Feature Items</h1>
</div>
<div id="content">
<table width="98%" border="1" cellpadding="5">
<tr align="center" valign="top">
<td><strong><em><span class="style1"><?php echo $totalRows_rs_unclassified ?> </span> Total Items from your Search</em></strong></td>
<td><a href="unclassified_display.php">New Search</a></td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr bgcolor="#FF9933">
<td width="25%" align="center" ><em><strong>Item Title</strong></em></td>
<td width="25%" align="center"><strong><em>Item Price</em></strong></td>
<td width="25%" align="center"><strong><em>Post Location</em></strong></td>
<td width="25%" align="center"><strong><em>Item Detail</em></strong></td>
</tr>
<?php do { ?>
<tr>
<td align="center" valign="top"><?php echo highlightResults($row_rs_unclassified['ad_title'], stripslashes($_POST["search_title"])); ?></td>
<td align="center" valign="top">$<?php echo $row_rs_unclassified['ad_price']; ?></td>
<td align="center" valign="top"><?php echo highlightResults($row_rs_unclassified['ad_city_state'], stripslashes($_POST["search_location"])); ?></td>
<td align="center" valign="top"><table>
<tr>
<td><img src="images/detail.gif" width="24" height="18" alt="Item Detail" /></td>
<td><a href="unclassified_display_detail.php?ad_ID=<?php echo $row_rs_unclassified['ad_ID']; ?>">Click Here</a></td>
</tr>
</table></td>
</tr>
<?php } while ($row_rs_unclassified = mysql_fetch_assoc($rs_unclassified)); ?>
</table>
</div>
</div>
<?php include("footer_include.php")?>
</div>
</body>
</html>
<?php
mysql_free_result($rs_unclassified);
?>

Sign in to reply to this post

Jason ByrnesWebAssist

i think the error is occurring because there is already a where clause.


try changing:
$WADbSearch1_DefaultWhere = "0 != 0";


to :
$WADbSearch1_DefaultWhere = "AND 0 != 0";

Sign in to reply to this post

JBWebWorks

That got rid of the error but it still shows all records?

Sign in to reply to this post

JBWebWorks

I took the WHERE clause out of the recordset and used

$WADbSearch1_DefaultWhere = "0 != 0";

and it works as it should.

I do need the WHERE clause that I had, so i will have to figure that out.

Any suggestions?

thanks
Jim Balthrop

Sign in to reply to this post

Jason ByrnesWebAssist

add it as a condition in data assist search

select the ad_verify column and add use 'y' (without quotes) for the value.

Sign in to reply to this post

JBWebWorks

thanks Jason
that worked filtering the ad_verify field and i used
$WADbSearch1_DefaultWhere = "0 != 0";
and it shows no records when the page is accessed directly, but when a person clicks the submit button on the search page without any input in the search fields, it still shows all records.

I am using click the search form submit button as the trigger for the db search .

The search form action is the results page.

What can i do so that if the user clicks the submit button on the search form and it takes them to the results page, that no records are shown?

Here is link to the search page
unclassified_display.php

click on the search unclassified button without adding any search input and it goes to the results page and shows all records?

thanks for your help,
Jim balthrop

Sign in to reply to this post
loading

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