Unable to get a Record to Update...
I've used the DataAssist Update wizard to use a form to update a record of the logged in user. But every time I make a change to the field and hit submit it does not update the record. Any ideas why? Here is the code for the page...
<?php require_once("../WA_DataAssist/WA_AppBuilder_PHP.php"); ?>
<?php require_once('../Connections/conn_trafficx.php');?>
<?php require_once( "../WA_SecurityAssist/Helper_PHP.php" ); ?>
<?php
// WA Application Builder Update
if (isset($_POST["Update_x"])) // Trigger
{
$WA_connection = $conn_trafficx;
$WA_table = "Users";
$WA_redirectURL = "mypromo.php?update=success";
if (function_exists("rel2abs")) $WA_redirectURL = $WA_redirectURL?rel2abs($WA_redirectURL,dirname(__FILE__)):"";
$WA_keepQueryString = false;
$WA_indexField = "ID";
$WA_fieldNamesStr = "Offer1_Desc|Offer1_Link";
$WA_fieldValuesStr = "".((isset($_POST["Offer1_Desc"]))?$_POST["Offer1_Desc"]:"") ."" . "|" . "".((isset($_POST["Offer1_Link"]))?$_POST["Offer1_Link"]:"") ."";
$WA_columnTypesStr = "',none,''|',none,''";
$WA_comparisonStr = "=|=";
$WA_fieldNames = explode("|", $WA_fieldNamesStr);
$WA_fieldValues = explode("|", $WA_fieldValuesStr);
$WA_columns = explode("|", $WA_columnTypesStr);
$WA_where_fieldValuesStr = "".$_SESSION['UserDetails'] ."";
$WA_where_columnTypesStr = "none,none,NULL";
$WA_where_comparisonStr = "=";
$WA_where_fieldNames = explode("|", $WA_indexField);
$WA_where_fieldValues = explode("|", $WA_where_fieldValuesStr);
$WA_where_columns = explode("|", $WA_where_columnTypesStr);
$WA_where_comparisons = explode("|", $WA_where_comparisonStr);
$WA_connectionDB = $database_conn_trafficx;
mysql_select_db($WA_connectionDB, $WA_connection);
if (!session_id()) session_start();
$updateParamsObj = WA_AB_generateInsertParams($WA_fieldNames, $WA_columns, $WA_fieldValues, -1);
$WhereObj = WA_AB_generateWhereClause($WA_where_fieldNames, $WA_where_columns, $WA_where_fieldValues, $WA_where_comparisons );
$WA_Sql = "UPDATE `" . $WA_table . "` SET " . $updateParamsObj->WA_setValues . " WHERE " . $WhereObj->sqlWhereClause . "";
$MM_editCmd = mysql_query($WA_Sql, $WA_connection) or die(mysql_error());
if ($WA_redirectURL != "") {
if ($WA_keepQueryString && $WA_redirectURL != "" && isset($_SERVER["QUERY_STRING"]) && $_SERVER["QUERY_STRING"] !== "" && sizeof($_POST) > 0) {
$WA_redirectURL .= ((strpos($WA_redirectURL, '?') === false)?"?":"&").$_SERVER["QUERY_STRING"];
}
header("Location: ".$WA_redirectURL);
}
}
?>
<?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;
}
}
$colname_rs_UserDetails = "-1";
if (isset($_SESSION['UserDetails'])) {
$colname_rs_UserDetails = $_SESSION['UserDetails'];
}
mysql_select_db($database_conn_trafficx, $conn_trafficx);
$query_rs_UserDetails = sprintf("SELECT Offer1_Desc, Offer1_Link FROM Users WHERE ID = %s", GetSQLValueString($colname_rs_UserDetails, "int"));
$rs_UserDetails = mysql_query($query_rs_UserDetails, $conn_trafficx) or die(mysql_error());
$row_rs_UserDetails = mysql_fetch_assoc($rs_UserDetails);
$totalRows_rs_UserDetails = mysql_num_rows($rs_UserDetails);
$colname_rs_UserDetails = "-1";
if (isset($_SESSION['UserDetails'])) {
$colname_rs_UserDetails = $_SESSION['UserDetails'];
}
mysql_select_db($database_conn_trafficx, $conn_trafficx);
$query_rs_UserDetails = sprintf("SELECT * FROM Users WHERE ID = %s", GetSQLValueString($colname_rs_UserDetails, "int"));
$rs_UserDetails = mysql_query($query_rs_UserDetails, $conn_trafficx) or die(mysql_error());
$row_rs_UserDetails = mysql_fetch_assoc($rs_UserDetails);
$totalRows_rs_UserDetails = mysql_num_rows($rs_UserDetails);$colname_rs_UserDetails = "-1";
if (isset($_SESSION['UserDetails'])) {
$colname_rs_UserDetails = $_SESSION['UserDetails'];
}
mysql_select_db($database_conn_trafficx, $conn_trafficx);
$query_rs_UserDetails = sprintf("SELECT * FROM Users WHERE ID = %s", GetSQLValueString($colname_rs_UserDetails, "int"));
$rs_UserDetails = mysql_query($query_rs_UserDetails, $conn_trafficx) or die(mysql_error());
$row_rs_UserDetails = mysql_fetch_assoc($rs_UserDetails);
$totalRows_rs_UserDetails = mysql_num_rows($rs_UserDetails); ?>
<!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>
<?php include("includes/header.php"); ?>
<form>
<table class="WADADataTable" cellpadding="0" cellspacing="0" border="0">
<tr>
<th class="WADADataTableHeader">Desc:</th>
<td class="WADADataTableCell"><input type="text" name="Offer1_Desc" id="Offer1_Desc" value="<?php echo $row_rs_UserDetails['Offer1_Desc']; ?>" size="32" /></td>
</tr>
<tr>
<th class="WADADataTableHeader">Link:</th>
<td class="WADADataTableCell"><input type="text" name="Offer1_Link" id="Offer1_Link" value="<?php echo $row_rs_UserDetails['Offer1_Link']; ?>" size="32" /></td>
</tr>
</table>
<table class="WADADataNavButtons" border="0" cellpadding="0" cellspacing="0">
<tr>
<td class="WADADataNavButtonCell" nowrap="nowrap"><input type="image" name="Update" id="Update" value="Update" alt="Update" src="../WA_DataAssist/images/Slate/Traditional_update.gif" /></td>
<td class="WADADataNavButtonCell" nowrap="nowrap"><a href="home.php" title="Cancel"><img border="0" name="Cancel" id="Cancel" alt="Cancel" src="../WA_DataAssist/images/Slate/Traditional_cancel.gif" /></a></td>
</tr>
</table>
</form>
<p> </p>
<p> </p> <?php include("includes/footer.php"); ?>
</body>
</html>
<?php
mysql_free_result($rs_UserDetails);
?>