Skip to main content
Participant
July 24, 2007
Question

Dreamweaver CS3 Recordset Filter issue

  • July 24, 2007
  • 1 reply
  • 684 views
My set-up is DW CS3, Mac OS 10.4.10, PHP 5, MySQL 5, testing on localhost.

I have a PHP page created in DW CS3 that I know successfully passes on a primary key of an populated MySQL table. When I pass the primary key as a URL parameter in a text link from one page to another page, I start having problems ONLY when I use the Server Behavior panel to MODIFY the target RecordSet to Filter: ID to URL Parameter: ID - this results in no data listed at all which indicates to me that the recordset is not correctly reading the URL Parameter. If I change the Filter setting to none, I have no problems.

I don't know enough php or SQL code to debug. Please help.

Here's the DW code that reads the passed URL parameter with no problem:

<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$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_artgallery, $artgallery);
$query_rsdelete = "SELECT * FROM ARTISTS ORDER BY ARTISTID ASC";
$rsdelete = mysql_query($query_rsdelete, $artgallery) or die(mysql_error());
$row_rsdelete = mysql_fetch_assoc($rsdelete);
$totalRows_rsdelete = mysql_num_rows($rsdelete);
?>


Here's the DW code that gives problems when setting the RecordSet to Filter: ID to URL Parameter: ID
[CODE]
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$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;
}
}

$colname_rsdelete = "-1";
if (isset($_POST['ARTISTID'])) {
$colname_rsdelete = $_POST['ARTISTID'];
}
mysql_select_db($database_artgallery, $artgallery);
$query_rsdelete = sprintf("SELECT * FROM ARTISTS WHERE ARTISTID = %s ORDER BY ARTISTID ASC", GetSQLValueString($colname_rsdelete, "int"));
$rsdelete = mysql_query($query_rsdelete, $artgallery) or die(mysql_error());
$row_rsdelete = mysql_fetch_assoc($rsdelete);
$totalRows_rsdelete = mysql_num_rows($rsdelete);
?>
[/CODE]

This topic has been closed for replies.

1 reply

Inspiring
July 24, 2007
freestyle-acaat wrote:
> when I use the Server Behavior panel to MODIFY the target RecordSet to
> Filter: ID to URL Parameter: ID - this results in no data listed at all which
> indicates to me that the recordset is not correctly reading the URL Parameter.

> Here's the DW code that reads the passed URL parameter with no problem:

No it doesn't. The SQL query simply selects all records from the ARTISTS
table and orders them by ARTISTID.

> $query_rsdelete = "SELECT * FROM ARTISTS ORDER BY ARTISTID ASC";

> Here's the DW code that gives problems when setting the RecordSet to Filter:
> ID to URL Parameter: ID

Again, you're mistaken. The following section of code shows that the
filter has been set to FORM parameter, not URL parameter.

> $colname_rsdelete = "-1";
> if (isset($_POST['ARTISTID'])) {
> $colname_rsdelete = $_POST['ARTISTID'];
> }

If it had been set to URL parameter, the code would look like this:

$colname_rsdelete = "-1";
if (isset($_GET['ARTISTID'])) {
$colname_rsdelete = $_GET['ARTISTID'];
}

Moreover, the following SQL query shows that only one record will be
retrieved, not all of them.

> $query_rsdelete = sprintf("SELECT * FROM ARTISTS WHERE ARTISTID = %s ORDER BY
> ARTISTID ASC", GetSQLValueString($colname_rsdelete, "int"));

--
David Powers, Adobe Community Expert
Author, "The Essential Guide to Dreamweaver CS3" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/