close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

multiple records insert

Thread began 10/10/2013 12:33 am by QuiruNet | Last modified 10/11/2013 6:24 am by Jason Byrnes | 1907 views | 5 replies |

QuiruNet

multiple records insert

i am trying to do the multiple records insert, combining with file manipulation (upload files), but doesnt work, can you help me. thanks

This is the code:

<?php require_once('../Connections/lesmes.php'); ?>
<?php require_once("../webassist/database_management/wa_appbuilder_php.php"); ?>
<?php require_once("../webassist/file_manipulation/helperphp.php"); ?>
<?php
// WA_UploadResult1 Params Start
$WA_UploadResult1_Params = array();
// WA_UploadResult1_1 Start
$WA_UploadResult1_Params["WA_UploadResult1_1"] = array(
'UploadFolder' => "../upload/blog/",
'FileName' => "[FileName]",
'DefaultFileName' => "",
'ResizeType' => "2",
'ResizeWidth' => "790",
'ResizeHeight' => "120",
'ResizeFillColor' => "#FFFFFF" );
// WA_UploadResult1_1 End
// WA_UploadResult1 Params End
?>
<?php
WA_DFP_SetupUploadStatusStruct("WA_UploadResult1");
if(isset($_POST["subir"]) || isset($_POST["subir_x"])){
WA_DFP_UploadFiles("WA_UploadResult1", "textfield", "2", "[NewFileName]_[Increment]", "true", $WA_UploadResult1_Params);
}
?>
<?php
// WA DataAssist Multiple Inserts
if (isset($_POST["subir"]) || isset($_POST["subir_x"])) // Trigger
{
if (!session_id()) session_start();
$WA_loopedFields = array("textfield");
$WA_connection = $lesmes;
$WA_table = "novios_fotos";
$WA_redirectURL = "blog.php";
if (function_exists("rel2abs")) $WA_redirectURL = $WA_redirectURL?rel2abs($WA_redirectURL,dirname(__FILE__)):"";
$WA_keepQueryString = false;
$WA_fieldNamesStr = "catID|archivo";
$WA_columnTypesStr = "none,none,NULL|',none,''";
$WA_insertIfNotBlank = "textfield";
$WA_fieldNames = explode("|", $WA_fieldNamesStr);
$WA_columns = explode("|", $WA_columnTypesStr);
$WA_connectionDB = $database_lesmes;
$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 = "1" . $WA_AB_Split . "".WA_AB_getLoopedFieldValue("textfield", $WA_multipleInsertCounter) ."";
$WA_fieldValues = explode($WA_AB_Split, $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 = true;
$RepeatSelectionCounter_1_Iterations = "5";
?>
<!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" enctype="multipart/form-data" name="form1" id="form1">
<table width="100%" border="0" cellspacing="2" cellpadding="2">
<?php
// RepeatSelectionCounter_1 Begin Loop
$RepeatSelectionCounter_1_IterationsRemaining = $RepeatSelectionCounter_1_Iterations;
while($RepeatSelectionCounter_1_IterationsRemaining--){
if($RepeatSelectionCounterBasedLooping_1 || $row_None){
?>
<tr>
<td><label for="archivo"></label>
<label for="textfield"></label>
<input type="hidden" name="textfield_mihidden_<?php echo $RepeatSelectionCounter_1; ?>" id="textfield_mihidden_<?php echo $RepeatSelectionCounter_1; ?>" value="1" />
<input type="file" name="textfield_<?php echo $RepeatSelectionCounter_1; ?>" id="textfield_<?php echo $RepeatSelectionCounter_1; ?>" /></td>
<td>&nbsp;</td>
</tr>
<?php
} // RepeatSelectionCounter_1 Begin Alternate Content
else{
?>
<?php } // RepeatSelectionCounter_1 End Alternate Content
if(!$RepeatSelectionCounterBasedLooping_1 && $RepeatSelectionCounter_1_IterationsRemaining != 0){
if(!$row_None && $RepeatSelectionCounter_1_Iterations == -1){$RepeatSelectionCounter_1_IterationsRemaining = 0;}
$row_None = mysql_fetch_assoc($None);
}
$RepeatSelectionCounter_1++;
} // RepeatSelectionCounter_1 End Loop
?>
<tr>
<td><input type="submit" name="subir" id="subir" value="Alta" /></td>
<td>&nbsp;</td>
</tr>
</table>
</form>
</body>
</html>

Sign in to reply to this post

Jason ByrnesWebAssist

File upload will not work with multiple record insert, this is not supported.

Sign in to reply to this post

QuiruNet

need help

can you tell me other way than i can upload multiple files into a datadabe, if i have 5 files to upload to put in different recordID in the same table. Thanks

Sign in to reply to this post

Jason ByrnesWebAssist

add 5 file fields, 5 upload file server behaviors and 5 insert record server behaviors to the page.

Sign in to reply to this post

QuiruNet

info

i did that you told me, but it insert 5 times, but wiht out the images doesnt upload and doesnt saber in the databaxe field. i put the dataassit insert All Upload Successful, but doesn upload anything. Other problem is than if you of the fieds i dont wanto to upload a file the dataassit insert a empty field in the database...see de code:

<?php require_once('../Connections/lesmes.php'); ?>
<?php require_once("../webassist/file_manipulation/helperphp.php"); ?>
<?php require_once("../webassist/database_management/wa_appbuilder_php.php"); ?>
<?php
// WA_UploadResult1 Params Start
$WA_UploadResult1_Params = array();
// WA_UploadResult1_1 Start
$WA_UploadResult1_Params["WA_UploadResult1_1"] = array(
'UploadFolder' => "undefined",
'FileName' => "[FileName]",
'DefaultFileName' => "",
'ResizeType' => "2",
'ResizeWidth' => "790",
'ResizeHeight' => "120",
'ResizeFillColor' => "#FFFFFF" );
// WA_UploadResult1_1 End
// WA_UploadResult1 Params End?>
<?php
// WA_UploadResult2 Params Start
$WA_UploadResult2_Params = array();
// WA_UploadResult2_1 Start
$WA_UploadResult2_Params["WA_UploadResult2_1"] = array(
'UploadFolder' => "../upload/blog/",
'FileName' => "[FileName]",
'DefaultFileName' => "",
'ResizeType' => "2",
'ResizeWidth' => "790",
'ResizeHeight' => "120",
'ResizeFillColor' => "#FFFFFF" );
// WA_UploadResult2_1 End
// WA_UploadResult2 Params End?>
<?php
// WA_UploadResult3 Params Start
$WA_UploadResult3_Params = array();
// WA_UploadResult3_1 Start
$WA_UploadResult3_Params["WA_UploadResult3_1"] = array(
'UploadFolder' => "../upload/blog/",
'FileName' => "[FileName]",
'DefaultFileName' => "",
'ResizeType' => "2",
'ResizeWidth' => "790",
'ResizeHeight' => "120",
'ResizeFillColor' => "#FFFFFF" );
// WA_UploadResult3_1 End
// WA_UploadResult3 Params End?>
<?php
// WA_UploadResult4 Params Start
$WA_UploadResult4_Params = array();
// WA_UploadResult4_1 Start
$WA_UploadResult4_Params["WA_UploadResult4_1"] = array(
'UploadFolder' => "../upload/blog/",
'FileName' => "[FileName]",
'DefaultFileName' => "",
'ResizeType' => "2",
'ResizeWidth' => "790",
'ResizeHeight' => "120",
'ResizeFillColor' => "#FFFFFF" );
// WA_UploadResult4_1 End
// WA_UploadResult4 Params End?>
<?php
// WA_UploadResult5 Params Start
$WA_UploadResult5_Params = array();
// WA_UploadResult5_1 Start
$WA_UploadResult5_Params["WA_UploadResult5_1"] = array(
'UploadFolder' => "../upload/blog/",
'FileName' => "[FileName]",
'DefaultFileName' => "",
'ResizeType' => "2",
'ResizeWidth' => "790",
'ResizeHeight' => "120",
'ResizeFillColor' => "#FFFFFF" );
// WA_UploadResult5_1 End
// WA_UploadResult5 Params End
?>
<?php
WA_DFP_SetupUploadStatusStruct("WA_UploadResult1");
if(WA_DFP_AllUploadsSuccess()){
WA_DFP_UploadFiles("WA_UploadResult1", "archivo01", "2", "[NewFileName]_[Increment]", "true", $WA_UploadResult1_Params);
}
?>
<?php
WA_DFP_SetupUploadStatusStruct("WA_UploadResult2");
if(WA_DFP_AllUploadsSuccess()){
WA_DFP_UploadFiles("WA_UploadResult2", "archivo02", "2", "[NewFileName]_[Increment]", "true", $WA_UploadResult2_Params);
}?>
<?php
WA_DFP_SetupUploadStatusStruct("WA_UploadResult3");
if(WA_DFP_AllUploadsSuccess()){
WA_DFP_UploadFiles("WA_UploadResult3", "archivo03", "2", "[NewFileName]_[Increment]", "true", $WA_UploadResult3_Params);
}?>
<?php
WA_DFP_SetupUploadStatusStruct("WA_UploadResult4");
if(WA_DFP_AllUploadsSuccess()){
WA_DFP_UploadFiles("WA_UploadResult4", "archivo04", "2", "[NewFileName]_[Increment]", "true", $WA_UploadResult4_Params);
}?>
<?php
WA_DFP_SetupUploadStatusStruct("WA_UploadResult5");
if(WA_DFP_AllUploadsSuccess()){
WA_DFP_UploadFiles("WA_UploadResult5", "archivo05", "2", "[NewFileName]_[Increment]", "true", $WA_UploadResult5_Params);
}
?>
<?php
// WA DataAssist Insert
if (WA_DFP_AllUploadsSuccess()) // Trigger
{
$WA_connection = $lesmes;
$WA_table = "novios_fotos";
$WA_sessionName = "archi01";
$WA_redirectURL = "";
if (function_exists("rel2abs")) $WA_redirectURL = $WA_redirectURL?rel2abs($WA_redirectURL,dirname(__FILE__)):"";
$WA_keepQueryString = false;
$WA_fieldNamesStr = "catID|archivo";
$WA_fieldValuesStr = "1" . $WA_AB_Split . "".$WA_DFP_UploadStatus["WA_UploadResult1"]["serverFileName"] ."";
$WA_columnTypesStr = "none,none,NULL|',none,''";
$WA_fieldNames = explode("|", $WA_fieldNamesStr);
$WA_fieldValues = explode($WA_AB_Split, $WA_fieldValuesStr);
$WA_columns = explode("|", $WA_columnTypesStr);
$WA_connectionDB = $database_lesmes;
mysql_select_db($WA_connectionDB, $WA_connection);
@session_start();
$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());
$_SESSION[$WA_sessionName] = mysql_insert_id($WA_connection);
if ($WA_redirectURL != "") {
$WA_redirectURL = str_replace("[Insert_ID]",$_SESSION[$WA_sessionName],$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
// WA DataAssist Insert
if (WA_DFP_AllUploadsSuccess()) // Trigger
{
$WA_connection = $lesmes;
$WA_table = "novios_fotos";
$WA_sessionName = "archi02";
$WA_redirectURL = "blog.php";
if (function_exists("rel2abs")) $WA_redirectURL = $WA_redirectURL?rel2abs($WA_redirectURL,dirname(__FILE__)):"";
$WA_keepQueryString = false;
$WA_fieldNamesStr = "catID|archivo";
$WA_fieldValuesStr = "1" . $WA_AB_Split . "".$WA_DFP_UploadStatus["WA_UploadResult2"]["serverFileName"] ."";
$WA_columnTypesStr = "none,none,NULL|',none,''";
$WA_fieldNames = explode("|", $WA_fieldNamesStr);
$WA_fieldValues = explode($WA_AB_Split, $WA_fieldValuesStr);
$WA_columns = explode("|", $WA_columnTypesStr);
$WA_connectionDB = $database_lesmes;
mysql_select_db($WA_connectionDB, $WA_connection);
@session_start();
$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());
$_SESSION[$WA_sessionName] = mysql_insert_id($WA_connection);
if ($WA_redirectURL != "") {
$WA_redirectURL = str_replace("[Insert_ID]",$_SESSION[$WA_sessionName],$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
// WA DataAssist Insert
if (WA_DFP_AllUploadsSuccess()) // Trigger
{
$WA_connection = $lesmes;
$WA_table = "novios_fotos";
$WA_sessionName = "archi03";
$WA_redirectURL = "";
if (function_exists("rel2abs")) $WA_redirectURL = $WA_redirectURL?rel2abs($WA_redirectURL,dirname(__FILE__)):"";
$WA_keepQueryString = false;
$WA_fieldNamesStr = "catID|archivo";
$WA_fieldValuesStr = "1" . $WA_AB_Split . "".$WA_DFP_UploadStatus["WA_UploadResult3"]["serverFileName"] ."";
$WA_columnTypesStr = "none,none,NULL|',none,''";
$WA_fieldNames = explode("|", $WA_fieldNamesStr);
$WA_fieldValues = explode($WA_AB_Split, $WA_fieldValuesStr);
$WA_columns = explode("|", $WA_columnTypesStr);
$WA_connectionDB = $database_lesmes;
mysql_select_db($WA_connectionDB, $WA_connection);
@session_start();
$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());
$_SESSION[$WA_sessionName] = mysql_insert_id($WA_connection);
if ($WA_redirectURL != "") {
$WA_redirectURL = str_replace("[Insert_ID]",$_SESSION[$WA_sessionName],$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
// WA DataAssist Insert
if (WA_DFP_AllUploadsSuccess()) // Trigger
{
$WA_connection = $lesmes;
$WA_table = "novios_fotos";
$WA_sessionName = "archi04";
$WA_redirectURL = "";
if (function_exists("rel2abs")) $WA_redirectURL = $WA_redirectURL?rel2abs($WA_redirectURL,dirname(__FILE__)):"";
$WA_keepQueryString = false;
$WA_fieldNamesStr = "catID|archivo";
$WA_fieldValuesStr = "1" . $WA_AB_Split . "".$WA_DFP_UploadStatus["WA_UploadResult4"]["serverFileName"] ."";
$WA_columnTypesStr = "none,none,NULL|',none,''";
$WA_fieldNames = explode("|", $WA_fieldNamesStr);
$WA_fieldValues = explode($WA_AB_Split, $WA_fieldValuesStr);
$WA_columns = explode("|", $WA_columnTypesStr);
$WA_connectionDB = $database_lesmes;
mysql_select_db($WA_connectionDB, $WA_connection);
@session_start();
$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());
$_SESSION[$WA_sessionName] = mysql_insert_id($WA_connection);
if ($WA_redirectURL != "") {
$WA_redirectURL = str_replace("[Insert_ID]",$_SESSION[$WA_sessionName],$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
// WA DataAssist Insert
if (WA_DFP_AllUploadsSuccess()) // Trigger
{
$WA_connection = $lesmes;
$WA_table = "novios_fotos";
$WA_sessionName = "archi05";
$WA_redirectURL = "";
if (function_exists("rel2abs")) $WA_redirectURL = $WA_redirectURL?rel2abs($WA_redirectURL,dirname(__FILE__)):"";
$WA_keepQueryString = false;
$WA_fieldNamesStr = "catID|archivo";
$WA_fieldValuesStr = "1" . $WA_AB_Split . "".$WA_DFP_UploadStatus["WA_UploadResult5"]["serverFileName"] ."";
$WA_columnTypesStr = "none,none,NULL|',none,''";
$WA_fieldNames = explode("|", $WA_fieldNamesStr);
$WA_fieldValues = explode($WA_AB_Split, $WA_fieldValuesStr);
$WA_columns = explode("|", $WA_columnTypesStr);
$WA_connectionDB = $database_lesmes;
mysql_select_db($WA_connectionDB, $WA_connection);
@session_start();
$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());
$_SESSION[$WA_sessionName] = mysql_insert_id($WA_connection);
if ($WA_redirectURL != "") {
$WA_redirectURL = str_replace("[Insert_ID]",$_SESSION[$WA_sessionName],$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>
<html>
<head>
<meta charset="UTF-8">
<title>Untitled Document</title>
</head>

<body>
<form method="post" enctype="multipart/form-data" name="form1" id="form1">


<ul>

<li>
<label for="archivo02">File:</label>
<input type="file" name="archivo01" id="archivo01">
</li>
<li> <label for="archivo02">File:</label>
<input type="file" name="archivo02" id="archivo02"></li>
<li> <label for="archivo02">File:</label>
<input type="file" name="archivo03" id="archivo03"></li>
<li> <label for="archivo02">File:</label>
<input type="file" name="archivo04" id="archivo04"></li>
<li> <label for="archivo02">File:</label>
<input type="file" name="archivo05" id="archivo05"></li>
<li>
<input type="submit" name="submit" id="submit" value="Submit">
</li>
</ul>


</form>
</body>
</html>

Sign in to reply to this post

Jason ByrnesWebAssist

You set the trigger for the upload behavior to All Uploads Successful, That is circular logic. That means the uploads will only happen if the uploads are successful

you need to use the Form Submit button pressed trigger for the Upload behavior.


In the insert behaviors , you also use the All Uploads Successful. Instead you should use the "Upload archivo01 Successful" trigger in the first insert, use the "Upload archivo02 Successful" trigger in the second insert and so on.

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