PDA

View Full Version : Using With Dreamweaver 8 Insert Record Server Behavior


visser.ha378346
04-29-2009, 02:48 PM
Can someone assist me with how I can implement the DFP with using Dreamweaver 8's Insert Record Server Behavior.

My problem:
Image will not upload to the folder, but the record will insert in the db table
Image filename is not recorded in db field

CODE:
<?php
WA_DFP_SetupUploadStatusStruct("WA_UploadResult1");
if(isset($_POST["undefined"])){
WA_DFP_UploadFile("WA_UploadResult1", "image", "", "../../images/team/", "[FileName]", "2", "[FileName]_[Increment]", "0", "true", "59", "60");
}
?>

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO gymnast_links (company, link, image) VALUES (%s, %s, %s)",
GetSQLValueString($_POST['company'], "text"),
GetSQLValueString($_POST['link'], "text"),
GetSQLValueString($_POST['image'], "text"));

FORM:
<tr valign="baseline">
<td nowrap align="right">Image:</td>
<td><input name="image" type="file" id="image" />
(your image height should be no more than 60px) </td>
</tr>
<input type="hidden" name="MM_insert" value="form1">
<input name="image" type="hidden" id="image" />

Thank you!

Ray Borduin
04-29-2009, 02:53 PM
Make sure the upload code appears above the insert record code and that problem will be solved.

DW8's insert record server behavior doesn't allow you to update a column from anything other than a form field and it doesn't work with upload fields, so you need to edit code by hand to get this to work properly.

You can probably add a hidden form element to your page and bind the form name to that hidden field, then write code that sets the $_POST variable for that hidden field to be the name of the uploaded field before the dreamweaver insert code runs to get around that limitation.

visser.ha378346
04-29-2009, 03:08 PM
OK. The code is above the Insert Record Server Behavior

"DW8's insert record server behavior doesn't allow you to update a column from anything other than a form field and it doesn't work with upload fields, so you need to edit code by hand to get this to work properly.

You can probably add a hidden form element to your page and bind the form name to that hidden field, then write code that sets the $_POST variable for that hidden field to be the name of the uploaded field before the dreamweaver insert code runs to get around that limitation."

I guess you're going to need to help me with baby steps at this point.

Ray Borduin
04-30-2009, 08:19 AM
Really I would suggest getting DataAssist, which allows you to update a field with any value from any source not just directly from a form.

To use the DW Insert, you would:

1) add a hidden form element to the page
2) bind the update to the value of the hidden form element
3) in between the code that uploads the file and the code that inserts, add code:

<?php
$_POST['HiddenFormElementName'] = {server file name value from bindings};
?>

visser.ha378346
04-30-2009, 11:15 AM
Unfortunately the cost is beyond the finances.

visser.ha378346
04-30-2009, 02:44 PM
Really I would suggest getting DataAssist, which allows you to update a field with any value from any source not just directly from a form.

To use the DW Insert, you would:

1) add a hidden form element to the page
2) bind the update to the value of the hidden form element
3) in between the code that uploads the file and the code that inserts, add code:

<?php
$_POST['HiddenFormElementName'] = {server file name value from bindings};
?>

OK. I have:
1) <input name="cc_img" type="hidden" id="cc_img" />
2) WA_DFP_SetupUploadStatusStruct("WA_UploadResult1");
if(isset($_POST["submit"])){
WA_DFP_UploadFile("WA_UploadResult1", "cc_img", "../../images/nophoto/No-Phot-Available.jpg", "../../photos/community_connections/", "[FileName]", "2", "[FileName]_[Increment]", "30", "true", "141", "119");
}
3) $_POST['cc_img'] = {server file name value from bindings};
**I don't understand what goes between the brackets.** Sorry. I'm a complete NEWBIE!

Ray Borduin
04-30-2009, 02:55 PM
Look in the bindings tab and drag and drop the value that says "server file name" for the upload. You should replace the brackets and the text inside with the code you drag and drop from the bindings tab.

visser.ha378346
04-30-2009, 04:00 PM
One more thing:

When I attempt to use the Upload in an Update Record Server Behavior using the same instructions provided above, I get a 'headers already sent' error message. Is using DFP with an Update Record Server Behavior need to be modified differently?

Ray Borduin
05-01-2009, 06:25 AM
You probably have a space or blank line in your server code. That is usually the cause of that error.