Using PHP/MySQL and DW8
I have 2 pages. First page displays a number of collections.
And the second page is my detail page. When I select a collection I
want to pass through the collection name to the detail page. So it
only displays the images for that collection. Then I will pass id
& collection name to another detailview page for a specific
item.
I can pass them through the URL like
collections.php?name=whatever (using colname in advanced RS). But I
keep getting an error on the detail page.
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 'WHERE client = 'client'' at line 1
Can how help me do this....
COLLECTIONS PAGE:
<?php require_once('../Connections/cmsConn.php'); ?>
<?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_cmsConn, $cmsConn);
$query_Recordset1 = "SELECT * FROM `work`";
$Recordset1 = mysql_query($query_Recordset1, $cmsConn) or
die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01
Transitional//EN" "
http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=ISO-8859-1">
<title>Untitled Document</title>
</head>
<body>
<a href="test2.php?id=<?php echo $row_Recordset1['id'];
?>&client=<?php echo $row_Recordset1['client'];
?>"><?php echo $row_Recordset1['client']; ?></a>
</body>
</html>
<?php
mysql_free_result($Recordset1);
?>
DETAIL PAGE:
<?php require_once('../Connections/cmsConn.php'); ?>
<?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_Recordset1 = "-1";
if (isset($_GET['id'])) {
$colname_Recordset1 = (get_magic_quotes_gpc()) ? $_GET['id']
: addslashes($_GET['id']);
}
$varclient_Recordset1 = "client";
if (isset($row_Recordset1['client'])) {
$varclient_Recordset1 = (get_magic_quotes_gpc()) ?
$row_Recordset1['client'] : addslashes($row_Recordset1['client']);
}
mysql_select_db($database_cmsConn, $cmsConn);
$query_Recordset1 = sprintf("SELECT * FROM `work` WHERE id =
%s & WHERE client = %s", GetSQLValueString($colname_Recordset1,
"text"),GetSQLValueString($varclient_Recordset1, "text"));
$Recordset1 = mysql_query($query_Recordset1, $cmsConn) or
die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01
Transitional//EN" "
http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=ISO-8859-1">
<title>Untitled Document</title>
</head>
<body>
<?php echo $row_Recordset1['client']; ?>
<?php echo $row_Recordset1['brief']; ?>
<?php echo $row_Recordset1['id']; ?>
</body>
</html>
<?php
mysql_free_result($Recordset1);
?>