Copy link to clipboard
Copied
I followed the tutorial and used the wizard, but no data displays in the update page form. The admin page calls for " /admin/property_change.php?=150836 " which is correct. The insert new record page works (created following same tutorial), the display records form on admin page works, but this update page and the error page do not work. I've found similar questions here but no answer to this. Any help is appreciated.
<?php require_once('../Connections/connSMBOP.php'); ?>
<?php
if (!isset($_SESSION)) {
session_start();
}
$MM_authorizedUsers = "";
$MM_donotCheckaccess = "true";
// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) {
// For security, start by assuming the visitor is NOT authorized.
$isValid = False;
// When a visitor has logged into this site, the Session variable MM_Username set equal to their username.
// Therefore, we know that a user is NOT logged in if that Session variable is blank.
if (!empty($UserName)) {
// Besides being logged in, you may restrict access to only certain users based on an ID established when they login.
// Parse the strings into arrays.
$arrUsers = Explode(",", $strUsers);
$arrGroups = Explode(",", $strGroups);
if (in_array($UserName, $arrUsers)) {
$isValid = true;
}
// Or, you may restrict access to only certain users based on their username.
if (in_array($UserGroup, $arrGroups)) {
$isValid = true;
}
if (($strUsers == "") && true) {
$isValid = true;
}
}
return $isValid;
}
$MM_restrictGoTo = "login.php";
if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {
$MM_qsChar = "?";
$MM_referrer = $_SERVER['PHP_SELF'];
if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
if (isset($QUERY_STRING) && strlen($QUERY_STRING) > 0)
$MM_referrer .= "?" . $QUERY_STRING;
$MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
header("Location: ". $MM_restrictGoTo);
exit;
}
?>
<?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;
}
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
$updateSQL = sprintf("UPDATE properties SET property_class=%s, address=%s, area=%s, price=%s, bedrooms=%s, baths_full=%s, baths_half=%s, sqfootage=%s, appliances=%s, land_size=%s, utilities_available=%s, zoning=%s, suitable_use=%s, remarks=%s, short_descript=%s WHERE mls=%s",
GetSQLValueString($_POST['property_class'], "text"),
GetSQLValueString($_POST['address'], "text"),
GetSQLValueString($_POST['area'], "text"),
GetSQLValueString($_POST['price'], "double"),
GetSQLValueString($_POST['bedrooms'], "int"),
GetSQLValueString($_POST['baths_full'], "int"),
GetSQLValueString($_POST['baths_half'], "int"),
GetSQLValueString($_POST['sqfootage'], "int"),
GetSQLValueString($_POST['appliances'], "text"),
GetSQLValueString($_POST['land_size'], "text"),
GetSQLValueString($_POST['utilities_available'], "text"),
GetSQLValueString($_POST['zoning'], "text"),
GetSQLValueString($_POST['suitable_use'], "text"),
GetSQLValueString($_POST['remarks'], "text"),
GetSQLValueString($_POST['short_descript'], "text"),
GetSQLValueString($_POST['mls'], "int"));
mysql_select_db($database_connSMBOP, $connSMBOP);
$Result1 = mysql_query($updateSQL, $connSMBOP) or die(mysql_error());
$updateGoTo = "admin.php";
if (isset($_SERVER['QUERY_STRING'])) {
$updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
$updateGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $updateGoTo));
}
$colname_rsUpdateProp = "-1";
if (isset($_SESSION['mls'])) {
$colname_rsUpdateProp = $_SESSION['mls'];
}
mysql_select_db($database_connSMBOP, $connSMBOP);
$query_rsUpdateProp = sprintf("SELECT * FROM properties WHERE mls = %s", GetSQLValueString($colname_rsUpdateProp, "int"));
$rsUpdateProp = mysql_query($query_rsUpdateProp, $connSMBOP) or die(mysql_error());
$row_rsUpdateProp = mysql_fetch_assoc($rsUpdateProp);
$colname_rsUpdateProp = "-1";
if (isset($_GET['mls'])) {
$colname_rsUpdateProp = $_GET['mls'];
}
mysql_select_db($database_connSMBOP, $connSMBOP);
$query_rsUpdateProp = sprintf("SELECT * FROM properties WHERE mls = %s", GetSQLValueString($colname_rsUpdateProp, "int"));
$rsUpdateProp = mysql_query($query_rsUpdateProp, $connSMBOP) or die(mysql_error());
$row_rsUpdateProp = mysql_fetch_assoc($rsUpdateProp);
$totalRows_rsUpdateProp = mysql_num_rows($rsUpdateProp);
?>
<!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>
</head>
<body>
<form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1">
<table align="center">
<tr valign="baseline">
<td align="right" valign="middle" nowrap="nowrap">Property Class:</td>
<td valign="baseline"><table>
<tr>
<td><input type="radio" name="property_class" value="Commercial" <?php if (!(strcmp(htmlentities($row_rsUpdateProp['property_class'], ENT_COMPAT, 'utf-8'),"Commercial"))) {echo "checked=\"checked\"";} ?> />
Commercial</td>
</tr>
<tr>
<td><input type="radio" name="property_class" value="Residential" <?php if (!(strcmp(htmlentities($row_rsUpdateProp['property_class'], ENT_COMPAT, 'utf-8'),"Residential"))) {echo "checked=\"checked\"";} ?> />
Residential</td>
</tr>
<tr>
<td><input type="radio" name="property_class" value="Lot_Land" <?php if (!(strcmp(htmlentities($row_rsUpdateProp['property_class'], ENT_COMPAT, 'utf-8'),"Lot_Land"))) {echo "checked=\"checked\"";} ?> />
Lot_Land</td>
</tr>
</table></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">MLS:</td>
<td><?php echo $row_rsUpdateProp['mls']; ?></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Address:</td>
<td><input type="text" name="address" value="<?php echo htmlentities($row_rsUpdateProp['address'], ENT_COMPAT, 'utf-8'); ?>" size="45" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Area:</td>
<td><input type="text" name="area" value="<?php echo htmlentities($row_rsUpdateProp['area'], ENT_COMPAT, 'utf-8'); ?>" size="29" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Price:</td>
<td><input type="text" name="price" value="<?php echo htmlentities($row_rsUpdateProp['price'], ENT_COMPAT, 'utf-8'); ?>" size="17" />
(No " , " or " . ")</td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Bedrooms:</td>
<td><input type="text" name="bedrooms" value="<?php echo htmlentities($row_rsUpdateProp['bedrooms'], ENT_COMPAT, 'utf-8'); ?>" size="7" />
(Res.)</td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Baths Full:</td>
<td><input type="text" name="baths_full" value="<?php echo htmlentities($row_rsUpdateProp['baths_full'], ENT_COMPAT, 'utf-8'); ?>" size="7" />
(Res.)</td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Baths Half:</td>
<td><input type="text" name="baths_half" value="<?php echo htmlentities($row_rsUpdateProp['baths_half'], ENT_COMPAT, 'utf-8'); ?>" size="7" />
(Res.)</td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Sq. Footage:</td>
<td><input type="text" name="sqfootage" value="<?php echo htmlentities($row_rsUpdateProp['sqfootage'], ENT_COMPAT, 'utf-8'); ?>" size="17" />
(Res. & Com.) [No " , " ]</td>
</tr>
<tr valign="baseline">
<td align="right" valign="top" nowrap="nowrap"><p>Appliances: <br /> (Res.) </p></td>
<td><textarea name="appliances" cols="45" rows="3"><?php echo htmlentities($row_rsUpdateProp['appliances'], ENT_COMPAT, 'utf-8'); ?></textarea></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Land Size:</td>
<td><input type="text" name="land_size" value="<?php echo htmlentities($row_rsUpdateProp['land_size'], ENT_COMPAT, 'utf-8'); ?>" size="29" /></td>
</tr>
<tr valign="baseline">
<td align="right" valign="top" nowrap="nowrap">Utilities Available:</td>
<td><textarea name="utilities_available" cols="50" rows="3"><?php echo htmlentities($row_rsUpdateProp['utilities_available'], ENT_COMPAT, 'utf-8'); ?></textarea></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Zoning:</td>
<td><input type="text" name="zoning" value="<?php echo htmlentities($row_rsUpdateProp['zoning'], ENT_COMPAT, 'utf-8'); ?>" size="32" /></td>
</tr>
<tr valign="baseline">
<td align="right" valign="top" nowrap="nowrap">Suitable Use:<br />
(Com.)</td>
<td><textarea name="suitable_use" cols="45" rows="3"><?php echo htmlentities($row_rsUpdateProp['suitable_use'], ENT_COMPAT, 'utf-8'); ?></textarea></td>
</tr>
<tr valign="baseline">
<td align="right" valign="top" nowrap="nowrap">Remarks:</td>
<td><textarea name="remarks" cols="50" rows="10"><?php echo htmlentities($row_rsUpdateProp['remarks'], ENT_COMPAT, 'utf-8'); ?></textarea></td>
</tr>
<tr valign="baseline">
<td align="right" valign="top" nowrap="nowrap">Short Description: <br />
(400 char.) </td>
<td><textarea name="short_descript" cols="50" rows="4"><?php echo htmlentities($row_rsUpdateProp['short_descript'], ENT_COMPAT, 'utf-8'); ?></textarea></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right"> </td>
<td><input type="submit" value="Update record" /></td>
</tr>
</table>
<input type="hidden" name="MM_update" value="form1" />
<input type="hidden" name="mls" value="<?php echo $row_rsUpdateProp['mls']; ?>" />
</form>
<p> </p>
</body>
</html>
<?php
mysql_free_result($rsUpdateProp);
?>
Copy link to clipboard
Copied
Thread moved to the Dreamweaver Application Development forum.
Copy link to clipboard
Copied
I finally figured out the problem my self. I guess the tutorials don't always include everything that you need.