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

rating

dataassist stopped multiple insets and updates?

Thread began 4/25/2011 6:14 am by ijs174940 | Last modified 4/25/2011 1:50 pm by Jason Byrnes | 859 views | 5 replies |

ijs174940Beta Tester

dataassist stopped multiple insets and updates?

Very strange but suddenly in the middle of designing a site I cannot get the multiple insert and update to work? I get no error in the page or via firebug I have

1) Uninstalled the extension and reinstalled it.
2) Updated the libary fix file
3) Deleted the WA_Dataassist folder
4) Removed all code from the page and remade it
5) Deleted wincache file

The page runs and there is no change to the db.

No idea of what to do next but I have to get this site finsihed in less than 24hrs so in a little bit of a panic. HELP..............

Code segment below

***************************************
<?php require_once('../Connections/GoCreate.php'); ?>
<?php require_once("../WA_DataAssist/WA_AppBuilder_PHP.php"); ?>
<?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;
}
}

mysql_select_db($database_GoCreate, $GoCreate);
$query_rs_DesignTypeDBAdd = "SELECT * FROM admin_media_type";
$rs_DesignTypeDBAdd = mysql_query($query_rs_DesignTypeDBAdd, $GoCreate) or die(mysql_error());
$row_rs_DesignTypeDBAdd = mysql_fetch_assoc($rs_DesignTypeDBAdd);
$totalRows_rs_DesignTypeDBAdd = mysql_num_rows($rs_DesignTypeDBAdd);

mysql_select_db($database_GoCreate, $GoCreate);
$query_rs_IncCheck = "SELECT * FROM des_res_type";
$rs_IncCheck = mysql_query($query_rs_IncCheck, $GoCreate) or die(mysql_error());
$row_rs_IncCheck = mysql_fetch_assoc($rs_IncCheck);
$totalRows_rs_IncCheck = mysql_num_rows($rs_IncCheck);?>
<?php
// WA DataAssist Multiple Inserts
if ("" == "") // Trigger
{
if (!session_id()) session_start();
$WA_loopedFields = array("ID", "Type");
$WA_connection = $GoCreate;
$WA_table = "des_res_type";
$WA_redirectURL = "";
if (function_exists("rel2abs")) $WA_redirectURL = $WA_redirectURL?rel2abs($WA_redirectURL,dirname(__FILE__)):"";
$WA_keepQueryString = false;
$WA_fieldNamesStr = "DESIGN_ID|TYPE";
$WA_columnTypesStr = "none,none,NULL|none,none,NULL";
$WA_insertIfNotBlank = "";
$WA_fieldNames = explode("|", $WA_fieldNamesStr);
$WA_columns = explode("|", $WA_columnTypesStr);
$WA_connectionDB = $database_GoCreate;
$WA_multipleInsertCounter = 0;
mysql_select_db($WA_connectionDB, $WA_connection);
while (WA_AB_checkMultiInsertLoopedFieldsExist($WA_loopedFields, $WA_multipleInsertCounter)) {
if ($WA_insertIfNotBlank == "" || WA_AB_checkLoopedFieldsNotBlank(array($WA_insertIfNotBlank), $WA_multipleInsertCounter)) {
$WA_fieldValuesStr = "".WA_AB_getLoopedFieldValue("ID", $WA_multipleInsertCounter) ."" . "|" . "".WA_AB_getLoopedFieldValue("Type", $WA_multipleInsertCounter) ."";
$WA_fieldValues = explode("|", $WA_fieldValuesStr);
$insertParamsObj = WA_AB_generateInsertParams($WA_fieldNames, $WA_columns, $WA_fieldValues, -1);
$WA_Sql = "INSERT INTO `" . $WA_table . "` (" . $insertParamsObj->WA_tableValues . ") VALUES (" . $insertParamsObj->WA_dbValues . ")";
$MM_editCmd = mysql_query($WA_Sql, $WA_connection) or die(mysql_error());
}
$WA_multipleInsertCounter++;
}
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
// RepeatSelectionCounter_1 Initialization
$RepeatSelectionCounter_1 = 0;
$RepeatSelectionCounterBasedLooping_1 = false;
$RepeatSelectionCounter_1_Iterations = "-1";
?>
<!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="#" method="post" name="form1" id="form1">
<?php
// RepeatSelectionCounter_1 Begin Loop
$RepeatSelectionCounter_1_IterationsRemaining = $RepeatSelectionCounter_1_Iterations;
while($RepeatSelectionCounter_1_IterationsRemaining--){
if($RepeatSelectionCounterBasedLooping_1 || $row_rs_DesignTypeDBAdd){
?>
<label for="ID"></label>
<input type="hidden" name="ID_mihidden_<?php echo $RepeatSelectionCounter_1; ?>" id="ID_mihidden_<?php echo $RepeatSelectionCounter_1; ?>" value="1" />
<input name="ID_<?php echo $RepeatSelectionCounter_1; ?>" type="text" id="ID_<?php echo $RepeatSelectionCounter_1; ?>" value="<?php echo $_GET['ID'];?>" />
<label for="Type"></label>
<input name="Type_<?php echo $RepeatSelectionCounter_1; ?>" type="text" id="Type_<?php echo $RepeatSelectionCounter_1; ?>" value="<?php echo $row_rs_DesignTypeDBAdd['ID']; ?>" />
<?php echo $row_rs_DesignTypeDBAdd['MEDIA_TYPE']; ?> <br />
<?php
} // RepeatSelectionCounter_1 Begin Alternate Content
else{
?>
<?php } // RepeatSelectionCounter_1 End Alternate Content
if(!$RepeatSelectionCounterBasedLooping_1 && $RepeatSelectionCounter_1_IterationsRemaining != 0){
if(!$row_rs_DesignTypeDBAdd && $RepeatSelectionCounter_1_Iterations == -1){$RepeatSelectionCounter_1_IterationsRemaining = 0;}
$row_rs_DesignTypeDBAdd = mysql_fetch_assoc($rs_DesignTypeDBAdd);
}
$RepeatSelectionCounter_1++;
} // RepeatSelectionCounter_1 End Loop
?>
</form>
</body>
</html>
<?php
mysql_free_result($rs_DesignTypeDBAdd);

mysql_free_result($rs_IncCheck);
?>
*************************************

Sign in to reply to this post

Jason ByrnesWebAssist

The multiple insert behavior trigger is set to before page loads, change it to use Any Form Post, or currant page submit instead.

Also the ID form element is set to use the ID Querying variable, it should probably use a value from the recordset, no?

Sign in to reply to this post

ijs174940Beta Tester

What I am trying to do is check to see if there are any matches in rs_IncCheck and if the row result =0 then do the insert based on the content of the form with repeat region which is populated by rs_DesignTypeDBAdd all of which is hidden.

The page will then include an update form based on the content just inserted. But if the content is already in the des_res_type table it will ignore the insert form and just go straight to the update form.

I am doing it this way around so when the site admin add a new product and select an option button, all the options will already be listed there and each will just require a tick box to select if that option will be included with item, I can do all this section fine but I need the multiple insert to add the content to start the whole process off, there are options in the multi insert for "before page loads2 and "if record set is empty" is the page layout in the incorrect sequence?

Sign in to reply to this post

ijs174940Beta Tester

I have just tried it without the repeat region form but still get no db insert, it goes into the page fine but if I try to edit it I get a warning popup "Your page must contain form elements in a repeated region to use this interface" !

*****************************************
<?php require_once('../Connections/GoCreate.php'); ?>
<?php require_once("../WA_DataAssist/WA_AppBuilder_PHP.php"); ?>
<?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;
}
}

mysql_select_db($database_GoCreate, $GoCreate);
$query_rs_DesignTypeDBAdd = "SELECT * FROM admin_media_type";
$rs_DesignTypeDBAdd = mysql_query($query_rs_DesignTypeDBAdd, $GoCreate) or die(mysql_error());
$row_rs_DesignTypeDBAdd = mysql_fetch_assoc($rs_DesignTypeDBAdd);
$totalRows_rs_DesignTypeDBAdd = mysql_num_rows($rs_DesignTypeDBAdd);

mysql_select_db($database_GoCreate, $GoCreate);
$query_rs_IncCheck = "SELECT * FROM des_res_type";
$rs_IncCheck = mysql_query($query_rs_IncCheck, $GoCreate) or die(mysql_error());
$row_rs_IncCheck = mysql_fetch_assoc($rs_IncCheck);
$totalRows_rs_IncCheck = mysql_num_rows($rs_IncCheck);?>
<?php
// WA DataAssist Multiple Inserts
if (($totalRows_rs_IncCheck == 0)) // Trigger
{
if (!session_id()) session_start();
$WA_loopedFields = array("");
$WA_connection = $GoCreate;
$WA_table = "des_res_type";
$WA_redirectURL = "";
if (function_exists("rel2abs")) $WA_redirectURL = $WA_redirectURL?rel2abs($WA_redirectURL,dirname(__FILE__)):"";
$WA_keepQueryString = false;
$WA_fieldNamesStr = "DESIGN_ID|TYPE";
$WA_columnTypesStr = "none,none,NULL|none,none,NULL";
$WA_insertIfNotBlank = "";
$WA_fieldNames = explode("|", $WA_fieldNamesStr);
$WA_columns = explode("|", $WA_columnTypesStr);
$WA_connectionDB = $database_GoCreate;
$WA_multipleInsertCounter = 0;
mysql_select_db($WA_connectionDB, $WA_connection);
while (WA_AB_checkMultiInsertLoopedFieldsExist($WA_loopedFields, $WA_multipleInsertCounter)) {
if ($WA_insertIfNotBlank == "" || WA_AB_checkLoopedFieldsNotBlank(array($WA_insertIfNotBlank), $WA_multipleInsertCounter)) {
$WA_fieldValuesStr = "".$_GET['D_ID'] ."" . "|" . "".$row_rs_DesignTypeDBAdd['MEDIA_TYPE'] ."";
$WA_fieldValues = explode("|", $WA_fieldValuesStr);
$insertParamsObj = WA_AB_generateInsertParams($WA_fieldNames, $WA_columns, $WA_fieldValues, -1);
$WA_Sql = "INSERT INTO `" . $WA_table . "` (" . $insertParamsObj->WA_tableValues . ") VALUES (" . $insertParamsObj->WA_dbValues . ")";
$MM_editCmd = mysql_query($WA_Sql, $WA_connection) or die(mysql_error());
}
$WA_multipleInsertCounter++;
}
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);
}
}
?>
<!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>
</body>
</html>
<?php
mysql_free_result($rs_DesignTypeDBAdd);

mysql_free_result($rs_IncCheck);
?>

Sign in to reply to this post

ijs174940Beta Tester

Ok got it working, I didn&#8217;t fully understand the triggers for the db insert I thought if you set the trigger it will automatically activate, what I didn&#8217;t realise it still need a form submit so the trigger is more like a filter, so went back to the original hidden form but added a body onload event

<body onLoad="form1.submit();">

Form works fine now, however how can you use the trigger before page loads if it needs the form to be submitted? Am I missing something out here?

Sign in to reply to this post

Jason ByrnesWebAssist

The valid triggers depend on where the insert data is coming from.

A multiple insert behavior, will rely on form data, so before page load is not a vlaid trigger.

A single insert can rely on Session data, recordset data or form data.

If it relies on a recordset, or session data, then the before page load can be used.

Any time you are using form data though, before page load is not a valid trigger.

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

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