20 messaggi dal 23 luglio 2002
Spero che qualcuno mi possa aiutare!
Ho creato con dreamweaver un modulo che mi inserisce la risposta al messaggio di un forum e fin qui nessun problema.
Il problema nasce in quanto oltre a inviare questa nuova risposta vorrei fare in modo che nella riga del database dove compare il messaggio padre venisse implementata di uno la casella replycount.
Un'istruzione come questa dovrebbe essere corretta,
sSQL = "UPDATE FORUM_MESSAGES SET REPLYCOUNT = REPLYCOUNT + 1, LASTTHREADPOST = NOW() WHERE ID = ThreadParent(colonna che assume valore di collegamento al messaggiopadre)
conn.execute sSQL
ma non so come inserirla nella pagina DI INVIO al database dei dati.

879 messaggi dal 09 luglio 2002
www.i-studio.it
Puoi postare il codice (la parte dove avviene l'inserimento dei dati nel DB)?

Ciao
Alex



Internetworking Studio Srl
www.i-studio.it
20 messaggi dal 23 luglio 2002
ti posto l'intera pagina perchè essendo stato creato come dicevo con dreamweaver e non manualmente da me per motivi di tempo a disposizione non

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="../Connections/primapage.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")) = "form1") Then

MM_editConnection = MM_primapage_STRING
MM_editTable = "FORUM_MESSAGES"
MM_editRedirectUrl = "rispostaok.asp"
MM_fieldsStr = "requiredName|value|requiredEmail|value|requiredMESSAGE|value|Topic|value|ThreadParent|value|ParentMessage|value"
MM_columnsStr = "AuthorName|',none,''|AuthorEmail|',none,''|comments|',none,''|Topic|',none,''|ThreadParent|none,none,NULL|ParentMessage|none,none,NULL"

' 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
%>
<%
Dim rs_quattro__MMColParam
rs_quattro__MMColParam = "1"
If (Request.QueryString("ThreadParent") <> "") Then
rs_quattro__MMColParam = Request.QueryString("ThreadParent")
End If
%>

<%
Dim rs_quattro
Dim rs_quattro_numRows

Set rs_quattro = Server.CreateObject("ADODB.Recordset")
rs_quattro.ActiveConnection = MM_primapage_STRING
rs_quattro.Source = "SELECT * FROM FORUM_MESSAGES WHERE ID = " + Replace(rs_quattro__MMColParam, "'", "''") + ""
rs_quattro.CursorType = 0
rs_quattro.CursorLocation = 2
rs_quattro.LockType = 1
rs_quattro.Open()

rs_quattro_numRows = 0
%>
<%
Dim Repeat1__numRows
Dim Repeat1__index

Repeat1__numRows = 1
Repeat1__index = 0
rs_quattro_numRows = rs_quattro_numRows + Repeat1__numRows
%>

<%
'## Do some Cookie bits to see when last here
session("last_here_date") = Request.Cookies("date")
Response.Cookies("Date") = now()
Response.Cookies("Date").Expires = dateadd("d",365,now())

' if never been here before, set last_here_date to -10 days
if Session("last_here_date") = "" then
Session("last_here_date") = dateadd("d",-10,now())
End if

'## Function to display new icon
Function isNew(dt)
if datediff("s", session("last_here_date"), dt) > 1 then
isNew = "<font face='" & DefaultFontFace & "' color='" & NewFontColor & "' size='1'>New"
Else
isNew = " "
End If
End Function
%>
<html>
<head>
<script>

function checkrequired(which){

var pass=true

if (document.images){

for (i=0;i<which.length;i++){

var tempobj=which.elements[i]

if (tempobj.name.substring(0,8)=="required"){

if (((tempobj.type=="text"||tempobj.type=="textarea")&&tempobj.value=='')||(tempobj.type.toString().charAt(0)=="s"&&tempobj.selectedIndex==-1)){

pass=false

break

}

}

}

}

if (!pass){

alert("Non hai compilato correttamente il form. Alcune informazioni non sono state inserite. Clicca su OK e verifica l'errore")

return false

}

else

return true

}

</script>

<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript">
<!--
function mmLoadMenus() {
if (window.mm_menu_0708115036_0) return;
window.mm_menu_0708115036_0 = new Menu("root",130,20,"Arial, Helvetica, sans-serif",10,"#7999ba","#cc9900","#ffffff","#ffffff","left","middle",2,2,1000,-134,28,true,true,true,10,false,false);
mm_menu_0708115036_0.addMenuItem("forum");
mm_menu_0708115036_0.addMenuItem("chat");
mm_menu_0708115036_0.addMenuItem("album","location='../album.asp'");
mm_menu_0708115036_0.addMenuItem("gadget");
mm_menu_0708115036_0.hideOnMouseOut=true;
mm_menu_0708115036_0.bgColor='#ffffff';
mm_menu_0708115036_0.menuBorder=1;
mm_menu_0708115036_0.menuLiteBgColor='#ffffff';
mm_menu_0708115036_0.menuBorderBgColor='#006699';
window.mm_menu_0708115911_1 = new Menu("root",130,20,"Arial, Helvetica, sans-serif",10,"#7999ba","#cc9900","#ffffff","#ffffff","left","middle",2,2,1000,-134,28,true,true,true,10,false,false);
mm_menu_0708115911_1.addMenuItem("musicali");
mm_menu_0708115911_1.addMenuItem("gossip");
mm_menu_0708115911_1.addMenuItem("video");
mm_menu_0708115911_1.hideOnMouseOut=true;
mm_menu_0708115911_1.bgColor='#ffffff';
mm_menu_0708115911_1.menuBorder=1;
mm_menu_0708115911_1.menuLiteBgColor='#ffffff';
mm_menu_0708115911_1.menuBorderBgColor='#006699';
window.mm_menu_0708120259_2 = new Menu("root",130,20,"Arial, Helvetica, sans-serif",10,"#7999ba","#cc9900","#ffffff","#ffffff","left","middle",2,2,1000,-134,28,true,true,true,10,false,false);
mm_menu_0708120259_2.addMenuItem("midi");
mm_menu_0708120259_2.addMenuItem("mp3");
mm_menu_0708120259_2.addMenuItem("waw");
mm_menu_0708120259_2.hideOnMouseOut=true;
mm_menu_0708120259_2.bgColor='#ffffff';
mm_menu_0708120259_2.menuBorder=1;
mm_menu_0708120259_2.menuLiteBgColor='#ffffff';
mm_menu_0708120259_2.menuBorderBgColor='#006699';
window.mm_menu_0708120515_3 = new Menu("root",130,20,"Arial, Helvetica, sans-serif",10,"#7999ba","#cc9900","#ffffff","#ffffff","left","middle",2,2,1000,-134,28,true,true,true,10,false,false);
mm_menu_0708120515_3.addMenuItem("programma","location='../programma.asp'");
mm_menu_0708120515_3.addMenuItem("locali");
mm_menu_0708120515_3.hideOnMouseOut=true;
mm_menu_0708120515_3.bgColor='#ffffff';
mm_menu_0708120515_3.menuBorder=1;
mm_menu_0708120515_3.menuLiteBgColor='#ffffff';
mm_menu_0708120515_3.menuBorderBgColor='#006699';

mm_menu_0708120515_3.writeMenus();
} // mmLoadMenus()

function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d )&&d.all) x=d.all ; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i] ;
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->
</script>
<script language="JavaScript1.2" src="../mm_menu.js"></script>
</head>

<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onLoad="MM_preloadImages('images/homees_r2_c1_f2.gif','images/homees_r3_c3_f2.gif','images/homees_r3_c5_f2.gif','images/homees_r3_c7_f2.gif','images/homees_r3_c9_f2.gif')"><div align="center"> <div align="center">
<script language="JavaScript1.2">mmLoadMenus();</script>
<table width="730" border="0" align="center" cellpadding="0" cellspacing="0">
<!-- fwtable fwsrc="home.png" fwbase="homees.gif" fwstyle="Dreamweaver" fwdocid = "742308039" fwnested="0" -->
<tr>
<td><img src="../images/spacer.gif" width="94" height="1" border="0" alt=""></td>
<td><img src="../images/spacer.gif" width="18" height="1" border="0" alt=""></td>
<td><img src="../images/spacer.gif" width="75" height="1" border="0" alt=""></td>
<td><img src="../images/spacer.gif" width="19" height="1" border="0" alt=""></td>
<td><img src="../images/spacer.gif" width="75" height="1" border="0" alt=""></td>
<td><img src="../images/spacer.gif" width="18" height="1" border="0" alt=""></td>
<td><img src="../images/spacer.gif" width="76" height="1" border="0" alt=""></td>
<td><img src="../images/spacer.gif" width="18" height="1" border="0" alt=""></td>
<td><img src="../images/spacer.gif" width="94" height="1" border="0" alt=""></td>
<td><img src="../images/spacer.gif" width="243" height="1" border="0" alt=""></td>
<td><img src="../images/spacer.gif" width="1" height="1" border="0" alt=""></td>
</tr>
<tr>
<td colspan="10"><img name="homees_r1_c1" src="../images/homees_r1_c1.gif" width="730" height="39" border="0" alt=""></td>
<td><img src="../images/spacer.gif" width="1" height="39" border="0" alt=""></td>
</tr>
<tr>
<td rowspan="2" colspan="2"><a href="default.asp" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('homees_r2_c1','','../images/homees_r2_c1_f2.gif',1);"><img name="homees_r2_c1" src="../images/homees_r2_c1.gif" width="112" height="31" border="0" alt=""></a></td>
<td colspan="8"><img name="homees_r2_c3" src="../images/homees_r2_c3.gif" width="618" height="11" border="0" alt=""></td>
<td><img src="../images/spacer.gif" width="1" height="11" border="0" alt=""></td>
</tr>
<tr>
<td colspan="2"><a href="#" onMouseOut="MM_swapImgRestore();MM_startTimeout();" onMouseOver="MM_showMenu(window.mm_menu_0708115036_0,0,22,null,'homees_r3_c3');MM_swapImage('homees_r3_c3','','../images/homees_r3_c3_f2.gif',1);"><img name="homees_r3_c3" src="../images/homees_r3_c3.gif" width="94" height="20" border="0" alt=""></a></td>
<td colspan="2"><a href="#" onMouseOut="MM_swapImgRestore();MM_startTimeout();" onMouseOver="MM_showMenu(window.mm_menu_0708115911_1,0,22,null,'homees_r3_c5');MM_swapImage('homees_r3_c5','','../images/homees_r3_c5_f2.gif',1);"><img name="homees_r3_c5" src="../images/homees_r3_c5.gif" width="93" height="20" border="0" alt=""></a></td>
<td colspan="2"><a href="#" onMouseOut="MM_swapImgRestore();MM_startTimeout();" onMouseOver="MM_showMenu(window.mm_menu_0708120259_2,0,22,null,'homees_r3_c7');MM_swapImage('homees_r3_c7','','../images/homees_r3_c7_f2.gif',1);"><img name="homees_r3_c7" src="../images/homees_r3_c7.gif" width="94" height="20" border="0" alt=""></a></td>
<td><a href="#" onMouseOut="MM_swapImgRestore();MM_startTimeout();" onMouseOver="MM_showMenu(window.mm_menu_0708120515_3,0,22,null,'homees_r3_c9');MM_swapImage('homees_r3_c9','','../images/homees_r3_c9_f2.gif',1);"><img name="homees_r3_c9" src="../images/homees_r3_c9.gif" width="94" height="20" border="0" alt=""></a></td>
<td><img name="homees_r3_c10" src="../images/homees_r3_c10.gif" width="243" height="20" border="0" alt=""></td>
<td><img src="../images/spacer.gif" width="1" height="20" border="0" alt=""></td>
</tr>
<tr>
<td colspan="9" valign="top" bgcolor="#ffffff"><p></p></td>
<td><img name="homees_r4_c10" src="../images/homees_r4_c10.gif" width="243" height="17" border="0" alt=""></td>
<td><img src="../images/spacer.gif" width="1" height="17" border="0" alt=""></td>
</tr>
</table


>
<table width="728" border="0" align="center">
<tr>
<td width="149"><font size="1" face="MS Sans Serif">| Cerca nel FORUM |</font></td>
<td width="255"> <div align="center"><font size="1" face="MS Sans Serif">|
<a href="default.asp"> Tutti i Forums</a> |</font></div></td>
<td width="306"><div align="right"><font size="1" face="MS Sans Serif"> Tua
Ultima visita: <%= session("last_here_date")%></font></div></td>
</tr>
</table>
<table width="730" border="0" align="center">
<tr>
<td width="730" height="300" align="center" valign="middle"><table width="728" border="0">
<tr>
<td width="250" align="left" valign="top"><div align="left"><font size="2" face="MS Sans Serif"><strong>RISPOSTA
AL MESSAGGIO : </strong></font></div></td>
<td align="left" valign="top"><font size="2" face="MS Sans Serif"><%=(rs_quattro.Fields.Item("Topic").Value)%></font></td>
</tr>
</table>
<table width="728" border="0">
<tr>
<td><form METHOD="POST" name="form1" action="<%=MM_editAction%>" onSubmit="return checkrequired(this)">
<table width="450" border="0" align="center">
<%
While ((Repeat1__numRows <> 0) AND (NOT rs_quattro.EOF))
%>
<tr>
<td width="200" align="center" valign="middle"><font size="2" face="MS Sans Serif">NICKNAME:</font></td>
<td width="250" align="left" valign="middle"><font size="2" face="MS Sans Serif">
<input name="requiredName" type="text" id="requiredName" size="40">
</font></td>
</tr>
<tr>
<td align="center" valign="middle"><font size="2" face="MS Sans Serif">E-MAIL:</font></td>
<td align="left" valign="middle"><font size="2" face="MS Sans Serif">
<input name="requiredEmail" type="text" id="requiredEmail" size="40">
</font></td>
</tr>
<tr>
<td align="center" valign="middle"><font size="2" face="MS Sans Serif">MESSAGGIO:</font></td>
<td align="left" valign="middle"><font size="2" face="MS Sans Serif">
<textarea name="requiredMESSAGE" cols="34" rows="4" id="requiredMESSAGE"></textarea>
</font></td>
</tr>
<tr>
<td align="center" valign="middle"><input name="Topic" type="hidden" id="Topic" value="[ Risposta ]">
</td>
<td align="left" valign="middle"><input name="ThreadParent" type="hidden" id="ThreadParent" value="<%=(rs_quattro.Fields.Item("ThreadParent").Value)%>">
<input name="ParentMessage" type="hidden" id="ParentMessage" value="<%=(rs_quattro.Fields.Item("ParentMessage").Value)%>">
</td>
</tr>
<tr>
<td align="center" valign="middle"> </td>
<td align="left" valign="middle"><input type="submit" name="Submit" value="Invia Risposta"></td>
</tr>
<%
Repeat1__index=Repeat1__index+1
Repeat1__numRows=Repeat1__numRows-1
rs_quattro.MoveNext()
Wend
%>
</table>
<input type="hidden" name="MM_insert" value="form1">
</form></td>
</tr>
</table> so esattamente quale la parte che esegue l'insert

879 messaggi dal 09 luglio 2002
www.i-studio.it
La parte di inserimento dovrebbe essere quella che inizia con:

' *** Insert Record: construct a sql insert statement and execute it

e l'inserimento avviene esattamente alla linea:

MM_editCmd.Execute

Quindi la parte che vuoi inserire dovrebbe essere inserita cosi':

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

sSQL = "UPDATE FORUM_MESSAGES SET REPLYCOUNT = REPLYCOUNT + 1, LASTTHREADPOST = NOW() WHERE ID = " & request("ThreadParent")
MM_editConnection.execute sSQL

If (MM_editRedirectUrl <> "") Then
Response.Redirect(MM_editRedirectUrl)
End If
End If


Ciao
Alex



Internetworking Studio Srl
www.i-studio.it
20 messaggi dal 23 luglio 2002
Il tuo aiuto alex è stato prezioso inquanto ho risolto il problema.

Ti posto la soluzione precisa al problema potrebbe essere utile:
nella parte dello script che tu mi hai segnalato la query personale è da impostare in questo modo

' *** Insert Record: construct a sql insert statement and execute it

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
si aggiunge qui la nuova query personale così
MM_editCmd.CommandText = UPDATE FORUM_MESSAGES SET REPLYCOUNT = REPLYCOUNT + 1, LASTTHREADPOST = NOW() WHERE ID = " & request("ThreadParent")
MM_editCmd.Execute

MM_editCmd.ActiveConnection.Close



If (MM_editRedirectUrl <> "") Then
Response.Redirect(MM_editRedirectUrl)
End If
End If

Saluti



Torna al forum | Feed RSS

ASPItalia.com non è responsabile per il contenuto dei messaggi presenti su questo servizio, non avendo nessun controllo sui messaggi postati nei propri forum, che rappresentano l'espressione del pensiero degli autori.