close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

Unable to get a Record to Update...

Thread began 6/04/2012 4:55 am by iamdan356160 | Last modified 6/04/2012 8:01 am by iamdan356160 | 626 views | 1 replies

iamdan356160

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>&nbsp;</p>
<p>&nbsp;</p> <?php include("includes/footer.php"); ?>
</body>
</html>
<?php
mysql_free_result($rs_UserDetails);
?>

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