Avatar billede mvk Nybegynder
03. juni 2003 - 10:22 Der er 9 kommentarer og
1 løsning

Kan ikke skrive til databasen

jeg kan simpelthen ikke se hvor fejlen opstår
http://www.capitolshop.dk/admin/html.asp
jeg prøver at skrive værdien fra HTML feltet til feltet MainText i databasen, men som i kan se bliver det ikke indsat.
pls help - kan ikke finde fejlen
Avatar billede mccannon Nybegynder
03. juni 2003 - 10:26 #1
har du noget kode man kan se ?
Avatar billede mvk Nybegynder
03. juni 2003 - 10:41 #2
dette er koden til html.asp

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="../Connections/capitol.asp" -->
<%
' *** Edit Operations: declare variables

Dim MM_editAction
Dim MM_abortEdit
Dim MM_editQuery
Dim MM_editCmd

Dim MM_editConnection
Dim MM_editTable
Dim MM_editRedirectUrl
Dim MM_editColumn
Dim MM_recordId

Dim MM_fieldsStr
Dim MM_columnsStr
Dim MM_fields
Dim MM_columns
Dim MM_typeArray
Dim MM_formVal
Dim MM_delim
Dim MM_altVal
Dim MM_emptyVal
Dim MM_i

MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME"))
If (Request.QueryString <> "") Then
  MM_editAction = MM_editAction & "?" & Request.QueryString
End If

' boolean to abort record edit
MM_abortEdit = false

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

If (CStr(Request("MM_insert")) = "fHtmlEditor") Then

  MM_editConnection = MM_capitol_STRING
  MM_editTable = "articles"
  MM_editRedirectUrl = "htmlview.asp"
  MM_fieldsStr  = "headline|value|EditorValue|value"
  MM_columnsStr = "Headline|',none,''|MainText|',none,''"

  ' create the MM_fields and MM_columns arrays
  MM_fields = Split(MM_fieldsStr, "|")
  MM_columns = Split(MM_columnsStr, "|")
 
  ' set the form values
  For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
    MM_fields(MM_i+1) = CStr(Request.Form(MM_fields(MM_i)))
  Next

  ' append the query string to the redirect URL
  If (MM_editRedirectUrl <> "" And Request.QueryString <> "") Then
    If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And Request.QueryString <> "") Then
      MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
    Else
      MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
    End If
  End If

End If
%>
<%
' *** Insert Record: construct a sql insert statement and execute it

Dim MM_tableValues
Dim MM_dbValues

If (CStr(Request("MM_insert")) <> "") Then

  ' create the sql insert statement
  MM_tableValues = ""
  MM_dbValues = ""
  For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
    MM_formVal = MM_fields(MM_i+1)
    MM_typeArray = Split(MM_columns(MM_i+1),",")
    MM_delim = MM_typeArray(0)
    If (MM_delim = "none") Then MM_delim = ""
    MM_altVal = MM_typeArray(1)
    If (MM_altVal = "none") Then MM_altVal = ""
    MM_emptyVal = MM_typeArray(2)
    If (MM_emptyVal = "none") Then MM_emptyVal = ""
    If (MM_formVal = "") Then
      MM_formVal = MM_emptyVal
    Else
      If (MM_altVal <> "") Then
        MM_formVal = MM_altVal
      ElseIf (MM_delim = "'") Then  ' escape quotes
        MM_formVal = "'" & Replace(MM_formVal,"'","''") & "'"
      Else
        MM_formVal = MM_delim + MM_formVal + MM_delim
      End If
    End If
    If (MM_i <> LBound(MM_fields)) Then
      MM_tableValues = MM_tableValues & ","
      MM_dbValues = MM_dbValues & ","
    End If
    MM_tableValues = MM_tableValues & MM_columns(MM_i)
    MM_dbValues = MM_dbValues & MM_formVal
  Next
  MM_editQuery = "insert into " & MM_editTable & " (" & MM_tableValues & ") values (" & MM_dbValues & ")"

  If (Not MM_abortEdit) Then
    ' execute the insert
    Set 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 <> "") Then
      Response.Redirect(MM_editRedirectUrl)
    End If
  End If

End If
%>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<style type="text/css">
<!--
.clsCursor {  cursor: hand}
-->
</style>
<form name="fHtmlEditor" method="POST" action="<%=MM_editAction%>">
  <input name="headline" type="text" id="headline">
  <br>
  <textarea name="EditorValue" style="display: none;"></textarea>
  <script language="JavaScript">

  var errorString = "Sorry but this web page needs\nWindows95 and Internet Explorer 5 or above to view."
  var Ok = "false";
  var name =  navigator.appName;
  var version =  parseFloat(navigator.appVersion);
  var platform = navigator.platform;

    if (platform == "Win32" && name == "Microsoft Internet Explorer" && version >= 4){
        Ok = "true";
    } else {
        Ok= "false";
    }

    if (Ok == "false") {
        alert(errorString);
    }

function ColorPalette_OnClick(colorString){
   
    cpick.bgColor=colorString;
    document.all.colourp.value=colorString;
    doFormat('ForeColor',colorString);
}

function initToolBar(ed) {
   
    var eb = document.all.editbar;
    if (ed!=null) {
        eb._editor = window.frames['myEditor'];
    }
}

function doFormat(what) {

    var eb = document.all.editbar;
       
    if(what == "FontName"){
        if(arguments[1] != 1){
            eb._editor.execCommand(what, arguments[1]);
            document.all.font.selectedIndex = 0;
        }
    } else if(what == "FontSize"){
    if(arguments[1] != 1){
      eb._editor.execCommand(what, arguments[1]);
      document.all.size.selectedIndex = 0;
    }
    } else {
      eb._editor.execCommand(what, arguments[1]);
    }
}

function swapMode() {

    var eb = document.all.editbar._editor;
  eb.swapModes();
}

function create() {

    var eb = document.all.editbar;
    eb._editor.newDocument();
}

function newFile(){

    create();
}

function makeUrl(){

    sUrl = document.all.what.value + document.all.url.value;
    doFormat('CreateLink',sUrl);
}

function copyValue() {

    var theHtml = "" + document.frames("myEditor").document.frames("textEdit").document.body.innerHTML + "";
    document.all.EditorValue.value = theHtml;
}

function SwapView_OnClick(){

  if(document.all.btnSwapView.value == "View Html"){
        var sMes = "View Wysiwyg";
    var sStatusBarMes = "Current View Html";
    } else {
        var sMes = "View Html"
    var sStatusBarMes = "Current View Wysiwyg";
  }
   
    document.all.btnSwapView.value = sMes;
  window.status  = sStatusBarMes;
    swapMode();
}

function Help_OnClick(){
  window.open("editor_images/help_document.htm","wHelp", "toolbar=0, scrollbars=yes, width=640, height=480");
}

function OnFormSubmit(){

  if(confirm("This Document is about to be submitted\nAre you sure you have finished editing?")){
    copyValue();
    document.fHtmlEditor.submit();
  }
}
</script>
  <table border="0" cellspacing="0" cellpadding="0" bgcolor="" width="50" height="60" bordercolor="">
    <tr valign="top">
      <td> <table border="0" cellpadding="0" cellspacing="0" width="100%" height="100%">
          <tr valign="top">
            <td valign="top"> <div id=editbar >
                <table width="100%" border="0" cellpadding="0" cellspacing="0" align="left">
                  <tr>
                    <td> <table border="0" cellpadding="0" cellspacing="0">
                        <tr>
                          <td> <table border="0">
                              <tr valign="baseline">
                                <td nowrap> <img class='clsCursor' src="editor_images/new.gif" width="16" height="16" border="0" alt="Start Over / New File" onClick="newFile();">&nbsp
                                  <img class='clsCursor' src="editor_images/save.gif" width="16" height="16" border="0" alt="Save Document" onClick="OnFormSubmit()";>&nbsp
                                  <img class='clsCursor' src="editor_images/Cut.gif" width="16" height="16" border="0" alt="Cut " onClick="doFormat('Cut')">&nbsp
                                  <img class='clsCursor' src="editor_images/Copy.gif" width="16" height="16" border="0" alt="Copy" onClick="doFormat('Copy')">&nbsp
                                  <img class='clsCursor' src="editor_images/Paste.gif" border="0" alt="Paste" onClick="doFormat('Paste')" width="16" height="16">&nbsp
                                </td>
                              </tr>
                            </table></td>
                          <td> <table border="0">
                              <tr valign="baseline">
                                <td nowrap> <img class='clsCursor' src="editor_images/para_bul.gif" width="16" height="16" border="0" alt="Bullet List" onClick="doFormat('InsertUnorderedList');" >&nbsp
                                  <img class='clsCursor' src="editor_images/para_num.gif" width="16" height="16" border="0" alt="Numbered List" onClick="doFormat('InsertOrderedList');" >&nbsp
                                  <img class='clsCursor' src="editor_images/indent.gif" width="20" height="16" alt="Indent" onClick="doFormat('Indent')">&nbsp
                                  <img class='clsCursor' src="editor_images/outdent.gif" width="20" height="16" alt="Outdent" onClick="doFormat('Outdent')">&nbsp
                                  <img class='clsCursor' src="editor_images/hr.gif" width="16" height="18" alt="HR" onClick="doFormat('InsertHorizontalRule')">&nbsp
                                </td>
                              </tr>
                            </table></td>
                          <td> <table border="0">
                              <tr valign="baseline">
                                <td nowrap><img src="editor_images/link.gif" border="0" alt="Link to external site"></td>
                                <td nowrap> <select name="what" style="font: 8pt verdana;">
                                    <option value="http://" selected>http://</option>
                                    <option value="mailto:">mailto:</option>
                                    <option value="ftp://">ftp://</option>
                                    <option value="https://">https://</option>
                                  </select> </td>
                                <td> <input type="text" name="url" size="35" style="font: 8pt verdana;">
                                </td>
                                <td> <input type="button" name="button2" value="Add" onClick="makeUrl();" style="font: 8pt verdana;">
                                </td>
                              </tr>
                            </table></td>
                          <td><img class='clsCursor' src="editor_images/help.gif" width="20" height="20" align="middle" alt="Help" onClick="Help_OnClick();">
                          </td>
                        </tr>
                      </table></td>
                  </tr>
                  <tr>
                    <td height="41"> <table border="0">
                        <tr>
                          <td nowrap valign="baseline"> <div align="left">
                              <select name="font" onChange=" doFormat('FontName',document.all.font.value);" style="font: 8pt verdana;">
                                <option value="1" selected >Select Font...</option>
                                <option value="arial">Arial, Helvetica, sans-serif</option>
                                <option value="times" >Times New Roman, Times,
                                serif</option>
                                <option value="courier">Courier New, Courier,
                                mono</option>
                                <option value="georgia">Georgia, Times New Roman</option>
                                <option value="verdana">Verdana, Arial, Helvetica</option>
                              </select>
                              <select name="size" onChange="doFormat('FontSize',document.all.size.value);" style="font: 8pt verdana;">
                                <option value="None" selected>Size</option>
                                <option value="1">1</option>
                                <option value="2">2</option>
                                <option value="3">3</option>
                                <option value="4">4</option>
                                <option value="5">5</option>
                                <option value="6">6</option>
                                <option value="7">7</option>
                                <option value="+1">+1</option>
                                <option value="+2">+2</option>
                                <option value="+3">+3</option>
                                <option value="+4">+4</option>
                                <option value="+5">+5</option>
                                <option value="+6">+6</option>
                                <option value="+7">+7</option>
                              </select>
                              <img class='clsCursor' src="editor_images/Bold.gif" width="16" height="16" border="0" align="absmiddle" alt="Bold text" onClick="doFormat('Bold')">&nbsp
                              <img class='clsCursor' src="editor_images/Italics.gif" width="16" height="16" border="0" align="absmiddle" alt="Italic text" onClick="doFormat('Italic')">&nbsp
                              <img class='clsCursor' src="editor_images/underline.gif" width="16" height="16" border="0" align="absmiddle" alt="Underline text" onClick="doFormat('Underline')" >&nbsp
                              <img class='clsCursor' src="editor_images/left.gif" width="16" height="16" border="0" alt="Align Left" align="absmiddle"  onClick="doFormat('JustifyLeft')">
                              <img class='clsCursor' src="editor_images/centre.gif" width="16" height="16" border="0" alt="Align Center" align="absmiddle" onClick="doFormat('JustifyCenter')">&nbsp
                              <img class='clsCursor' src="editor_images/right.gif" width="16" height="16" border="0" alt="Align Right" align="absmiddle"  onClick="doFormat('JustifyRight')">&nbsp
                            </div></td>
                        </tr>
                      </table></td>
                  </tr>
                </table>
              </div></td>
          </tr>
          <tr valign="top" align="left">
            <td valign="top"> <table width="100%" border="0" height="100%">
                <tr valign="top">
                  <td width="100%" height="100%"> <table width="100%" border="0" cellspacing="0" cellpadding="0" height="100%">
                      <tr valign="top">
                        <td height="250" bgcolor="#FFFFFF"> <iframe id=myEditor src="pd_edit.htm" onfocus="initToolBar(this)" width=100% height=100%></iframe></td>
                      </tr>
                    </table></td>
                  <!-- COLORPICKER_GOES_HERE -->
                </tr>
              </table></td>
          </tr>
        </table></td>
    </tr>
  </table>
  <br>
  <input type="submit" name="Submit" value="Submit">
  <input type="hidden" name="MM_insert" value="fHtmlEditor">
</form>
<script>
  initToolBar("foo");
  window.status  = "Current View: Wysiwyg";
</script>
</body>
</html>
Avatar billede mvk Nybegynder
03. juni 2003 - 10:42 #3
det må være fordi den ikke rigtig finder HTML felter når jeg laver min Insert Record - men jeg kan ikke se hvor...
Avatar billede mccannon Nybegynder
03. juni 2003 - 10:55 #4
hmm det må jeg sige..jeg kan sgutte finde fejlen
Avatar billede baronen20 Nybegynder
03. juni 2003 - 12:34 #5
jeg har aldrig nogensinde set så uoverskuelig en kode... tillykke...
Avatar billede martinhh Nybegynder
04. juni 2003 - 21:01 #6
Kan heller ikke finde fejlen, men hold kæft man hvor er der meget kode!!! Du skal have en lidt mere overskuelig kode, både for din egen skyld, og for dem der skal svare på dit spørgsmål. Jeg har dog kigget den igennem, men jeg kan heller ikke se fejlen!

Mvh,
Martin Henriksen
Avatar billede oyderke Nybegynder
05. juni 2003 - 00:09 #7
Det kan være at du ikke kan skrive til databasen pga NTFS instillinger.
Avatar billede mvk Nybegynder
05. juni 2003 - 12:35 #8
funktionen er lavet med en dreamweaver extension:
http://www.capitolshop.dk/admin/MX125164_PD_Html_Editor.mxp
.
er der nogen som har tid til at kigge på den
Avatar billede tsunami Nybegynder
06. juni 2003 - 14:44 #9
Macromedia laver altid uoverskuelig kode... men til gændgæld er det nogle fede koder der nogengange bliver skrevet... men nok om det....

Har du prøvet at se om brugeren "Alle" eller den brugerkonto som er internet brugerne bruger logger sig ind som når de kigger på din hjemmeside, tilfældet her er nok en anonym konto, har skrive og læse rettigheder til databasen på Serveren?
Avatar billede mvk Nybegynder
24. juni 2003 - 11:29 #10
virker ikke. damn
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Kurser inden for grundlæggende programmering

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester