Hi All I have the following page:


If I remove the insert section it works fine it moves to the jmail file and
sends the email fine! But directly I ask it to insert a new record into the
data base at the same time it does not like it.

The code is automatically formed wihtin Dreamweaver. I'm not a coder and do
not have a fogiest how it works, All I know is that individually they work
fine but once I try to combine them it gets ed up.

Thanks for taking the time to look at it.
Jon


<%LANGUAGE="JAVASCRIPT" CODEPAGE="1252"%>
<!--#include file="../Connections/cnnSQLphoto4me.asp" -->
<%
// *** Edit Operations: declare variables

// set the form action variable
var MM_editAction = Request.ServerVariables("SCRIPT_NAME");
if (Request.QueryString) {
MM_editAction += "?" + Request.QueryString;
}

// boolean to abort record edit
var MM_abortEdit = false;

// query string to execute
var MM_editQuery = "";
%>
<%
// *** Insert Record: set variables

if (String(Request("MM_insert")) == "form1") {

var MM_editConnection = MM_cnnSQLphoto4me_STRING;
var MM_editTable = "dbo.tblPictureRating";
var MM_editRedirectUrl = "thanks_for_voting.asp";
var MM_fieldsStr =
"PictureID|value|UserID|value|Username|value|ratin g|value|comments|value";
var MM_columnsStr =
"PictureID|none,none,NULL|UserID|none,none,NULL|Us erName|',none,''|Rating|no
ne,none,NULL|Comments|',none,''";

// create the MM_fields and MM_columns arrays
var MM_fields = MM_fieldsStr.split("|");
var MM_columns = MM_columnsStr.split("|");

// set the form values
for (var i=0; i+1 < MM_fields.length; i+=2) {
MM_fields[i+1] = String(Request.Form(MM_fields[i]));
}

// append the query string to the redirect URL
if (MM_editRedirectUrl && Request.QueryString && Request.QueryString.Count
> 0) {
MM_editRedirectUrl += ((MM_editRedirectUrl.indexOf('?') == -1)?"?":"&")
+ Request.QueryString;
}
}
%>
<%
// *** Insert Record: construct a sql insert statement and execute it

if (String(Request("MM_insert")) != "undefined") {

// create the sql insert statement
var MM_tableValues = "", MM_dbValues = "";
for (var i=0; i+1 < MM_fields.length; i+=2) {
var formVal = MM_fields[i+1];
var MM_typesArray = MM_columns[i+1].split(",");
var delim = (MM_typesArray[0] != "none") ? MM_typesArray[0] : "";
var altVal = (MM_typesArray[1] != "none") ? MM_typesArray[1] : "";
var emptyVal = (MM_typesArray[2] != "none") ? MM_typesArray[2] : "";
if (formVal == "" || formVal == "undefined") {
formVal = emptyVal;
} else {
if (altVal != "") {
formVal = altVal;
} else if (delim == "'") { // escape quotes
formVal = "'" + formVal.replace(/'/g,"''") + "'";
} else {
formVal = delim + formVal + delim;
}
}
MM_tableValues += ((i != 0) ? "," : "") + MM_columns[i];
MM_dbValues += ((i != 0) ? "," : "") + formVal;
}
MM_editQuery = "insert into " + MM_editTable + " (" + MM_tableValues + ")
values (" + MM_dbValues + ")";

if (!MM_abortEdit) {
// execute the insert
var MM_editCmd = Server.CreateObject('ADODB.Command');
MM_editCmd.ActiveConnection = MM_editConnection;
MM_editCmd.CommandText = MM_editQuery;
MM_editCmd.Execute();
MM_editCmd.ActiveConnection.Close();

if (MM_editRedirectUrl) {
Response.Redirect(MM_editRedirectUrl);
}
}

}
%>
<HTML>
<BODY>
<FORM name="form1" METHOD="POST" ACTION="<%=MM_editAction%>">

Your email address: <INPUT TYPE="TEXT" NAME="MailTo"><BR>
The subject: <INPUT TYPE="TEXT" NAME="subject"><BR>
Your message: <INPUT TYPE="TEXT" NAME="body"><BR>
<INPUT TYPE="SUBMIT" VALUE="Send mail">
<input name="PictureID" type="hidden" id="PictureID" value="746">
<input name="UserID" type="hidden" id="UserID" value="1">
<input name="Username" type="hidden" id="Username" value="jonpanky">
<input name="rating" type="hidden" id="rating" value="4">
<input name="comments" type="hidden" id="comments" value="test">
<input type="hidden" name="MM_insert" value="form1">
</FORM>
</BODY>
</HTML>




--
Upgrade your 6mb to a 25mb mail box!
[url]http://www.spl.at[/url]