close ad
Databridge V2 with MySQLi support IS Now Available!
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues


Update Record Trigger

Thread began 6/18/2012 4:38 am by jason363662 | Last modified 6/19/2012 10:29 am by Jason Byrnes | 639 views | 4 replies |


Update Record Trigger

I have a multi-page form and I would like to have the last page update the record without any submission from the user. I'm passing a calculation based on a session variable and a timestamp and the user doesn't need to see it.

If I use the "before page load" trigger, which seems like the natural, it passes all null values from my fields.

If I change it to "Button <my button> Pressed" it works just fine.

What am I missing here?

Sign in to reply to this post

Ian S

This post has been deleted.

Jason ByrnesWebAssist

without seeing the code, it's rather tough to tell, but my gut says the issue is the order of the code.

I would guess that the code that perfumes the calculation is after the update record code, and it should be before.

Sign in to reply to this post


Here's the code - I moved the Update Record behavior down, still no dice

I thought this might be it as well, but I moved the behavior down and it still doesn't work. Keep in mind this form works fine if I trigger on button press, but no if I change trigger to Before Pageload. Is there some other code above that's triggering?

I stripped out everything from the form but the most important detail for this page of the form.


<?php require_once('../../Connections/cnArtsalaLcl.php'); ?>
<?php require_once( "../../webassist/security_assist/helper_php.php" ); ?>
<?php require_once("../../webassist/database_management/wa_appbuilder_php.php"); ?>
if (!WA_Auth_RulePasses("ArtistLoggedIn")){

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";
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
return $theValue;

$colname_rsArt = "-1";
if (isset($_SESSION['idNewArt'])) {
$colname_rsArt = $_SESSION['idNewArt'];
mysql_select_db($database_cnArtsalaLcl, $cnArtsalaLcl);
$query_rsArt = sprintf("SELECT idArt, Art_idArtist, Art_InvNum, artists.idArtists, artists.artist_invnumcurrent FROM art, artists WHERE idArt = %s AND Art_idArtist=artists.idArtists", GetSQLValueString($colname_rsArt, "int"));
$rsArt = mysql_query($query_rsArt, $cnArtsalaLcl) or die(mysql_error());
$row_rsArt = mysql_fetch_assoc($rsArt);
$totalRows_rsArt = mysql_num_rows($rsArt);?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>

<form id="form1" name="form1" method="post" action="">
<label for="CurrInvNum"></label>
<input name="CurrInvNum" type="text" id="CurrInvNum" value="<?php echo $row_rsArt['Art_InvNum']+1; ?>" />
<input type="submit" name="submit" id="submit" value="Submit" />
// WA DataAssist Update
if ("" == "") // Trigger
$WA_connection = $cnArtsalaLcl;
$WA_table = "artists";
$WA_redirectURL = "../index.php";
if (function_exists("rel2abs")) $WA_redirectURL = $WA_redirectURL?rel2abs($WA_redirectURL,dirname(__FILE__)):"";
$WA_keepQueryString = false;
$WA_indexField = "idArtists";
$WA_fieldNamesStr = "artist_invnumcurrent";
$WA_fieldValuesStr = "".((isset($_POST["CurrInvNum"]))?$_POST["CurrInvNum"]:"") ."";
$WA_columnTypesStr = "none,none,NULL";
$WA_comparisonStr = "=";
$WA_fieldNames = explode("|", $WA_fieldNamesStr);
$WA_fieldValues = explode($WA_AB_Split, $WA_fieldValuesStr);
$WA_columns = explode("|", $WA_columnTypesStr);

$WA_where_fieldValuesStr = "".$row_rsArt['idArtists'] ."";
$WA_where_columnTypesStr = "none,none,NULL";
$WA_where_comparisonStr = "=";
$WA_where_fieldNames = explode("|", $WA_indexField);
$WA_where_fieldValues = explode($WA_AB_Split, $WA_where_fieldValuesStr);
$WA_where_columns = explode("|", $WA_where_columnTypesStr);
$WA_where_comparisons = explode("|", $WA_where_comparisonStr);

$WA_connectionDB = $database_cnArtsalaLcl;
mysql_select_db($WA_connectionDB, $WA_connection);
$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);


Sign in to reply to this post

Ian S

Interesting... I have never seen a page with the insert behaviour at the bottom before.

It looks like you have set your behaviour to run on page load, but you are using POST values in it. I assume those values from a different page and that you are not trying to get a POST value from the current page without performing a POST event?


Sign in to reply to this post

Jason ByrnesWebAssist

in the update you are using a form value which wont exist unless the form is submitted, instead of using the form values in the update, use the recordset values that you are using to populate the form.

for example, the code you are using for the CurrInvNum form element:

<?php echo $row_rsArt['Art_InvNum']+1?>

use that in the update for the value of the artist_invnumcurrent instead of binding to the CurrInvNum form element

Sign in to reply to this post

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





Ease of use


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