close ad
WARNING: Do Not Install the DREAMWEAVER CC 2017 or 2018 Update »
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Database Search Wizard Question

Thread began 10/12/2015 8:27 am by sfranzken73972 | Last modified 10/13/2015 1:18 pm by Ray Borduin | 583 views | 6 replies |

sfranzken73972

Database Search Wizard Question

Just noticed on my search results page there are a few recordsets.

Is this normal?

<?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;
}
}

$maxRows_rsresults = 12;
$pageNum_rsresults = 0;
if (isset($_GET['pageNum_rsresults'])) {
$pageNum_rsresults = $_GET['pageNum_rsresults'];
}
$startRow_rsresults = $pageNum_rsresults * $maxRows_rsresults;

mysql_select_db($database_connreyou, $connreyou);
$query_rsresults = "SELECT id, cid, sid, posttitle, postdetails, city, `state`, zipcode FROM posts ORDER BY datepublished DESC";
$query_limit_rsresults = sprintf("%s LIMIT %d, %d", $query_rsresults, $startRow_rsresults, $maxRows_rsresults);
$rsresults = mysql_query($query_limit_rsresults, $connreyou) or die(mysql_error());
$row_rsresults = mysql_fetch_assoc($rsresults);

if (isset($_GET['totalRows_rsresults'])) {
$totalRows_rsresults = $_GET['totalRows_rsresults'];
} else {
$all_rsresults = mysql_query($query_rsresults, $connreyou);
$totalRows_rsresults = mysql_num_rows($all_rsresults);
}
$totalPages_rsresults = ceil($totalRows_rsresults/$maxRows_rsresults)-1;$maxRows_rsresults = 12;
$pageNum_rsresults = 0;
if (isset($_GET['pageNum_rsresults'])) {
$pageNum_rsresults = $_GET['pageNum_rsresults'];
}
$startRow_rsresults = $pageNum_rsresults * $maxRows_rsresults;

mysql_select_db($database_connreyou, $connreyou);
$query_rsresults = "SELECT id, cid, sid, posttitle, postdetails, city, `state`, zipcode FROM posts ORDER BY datepublished DESC";
$query_limit_rsresults = sprintf("%s LIMIT %d, %d", $query_rsresults, $startRow_rsresults, $maxRows_rsresults);
$rsresults = mysql_query($query_limit_rsresults, $connreyou) or die(mysql_error());
$row_rsresults = mysql_fetch_assoc($rsresults);

if (isset($_GET['totalRows_rsresults'])) {
$totalRows_rsresults = $_GET['totalRows_rsresults'];
} else {
$all_rsresults = mysql_query($query_rsresults, $connreyou);
$totalRows_rsresults = mysql_num_rows($all_rsresults);
}
$totalPages_rsresults = ceil($totalRows_rsresults/$maxRows_rsresults)-1;
$query_rsresults = "SELECT id, cid, sid, posttitle, postdetails, city, `state`, zipcode FROM posts ORDER BY datepublished DESC";
setQueryBuilderSource($query_rsresults,$WADbSearch1,false);
$rsresults = mysql_query($query_rsresults, $connreyou) or die(mysql_error());
$row_rsresults = mysql_fetch_assoc($rsresults);
$totalRows_rsresults = mysql_num_rows($rsresults);

Sign in to reply to this post

Ray BorduinWebAssist

Dreamweaver will create a second copy sometimes when editing a recordset. You can delete all but the last one, since they are overwritten anyway and aren't being used like:


$maxRows_rsresults = 12;
$pageNum_rsresults = 0;
if (isset($_GET['pageNum_rsresults'])) {
$pageNum_rsresults = $_GET['pageNum_rsresults'];
}
$startRow_rsresults = $pageNum_rsresults * $maxRows_rsresults;

mysql_select_db($database_connreyou, $connreyou);
$query_rsresults = "SELECT id, cid, sid, posttitle, postdetails, city, `state`, zipcode FROM posts ORDER BY datepublished DESC";
$query_limit_rsresults = sprintf("%s LIMIT %d, %d", $query_rsresults, $startRow_rsresults, $maxRows_rsresults);
$rsresults = mysql_query($query_limit_rsresults, $connreyou) or die(mysql_error());
$row_rsresults = mysql_fetch_assoc($rsresults);

if (isset($_GET['totalRows_rsresults'])) {
$totalRows_rsresults = $_GET['totalRows_rsresults'];
} else {
$all_rsresults = mysql_query($query_rsresults, $connreyou);
$totalRows_rsresults = mysql_num_rows($all_rsresults);
}
$totalPages_rsresults = ceil($totalRows_rsresults/$maxRows_rsresults)-1;
$query_rsresults = "SELECT id, cid, sid, posttitle, postdetails, city, `state`, zipcode FROM posts ORDER BY datepublished DESC";
setQueryBuilderSource($query_rsresults,$WADbSearch1,false);
$rsresults = mysql_query($query_rsresults, $connreyou) or die(mysql_error());
$row_rsresults = mysql_fetch_assoc($rsresults);
$totalRows_rsresults = mysql_num_rows($rsresults);

Sign in to reply to this post

sfranzken73972

Getting an error

See private message

Attached Files
search-results.php
Sign in to reply to this post

Ray BorduinWebAssist

Change line 9 to:
$WADbSearch1_DefaultWhere = "WHERE 0<>0"

Sign in to reply to this post

sfranzken73972

Response

Still getting
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 posts.datepublished DESC' at line 5

Sign in to reply to this post

Ray BorduinWebAssist

Update line 51 to:
$WADbSearch1->whereClause = "WHERE 0 <> 0";

Sign in to reply to this post

sfranzken73972

Perfect

Thank you

Sign in to reply to this post

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