Salve a tuttie scusatemi anticipatamente per l'invadenza ho acquistato un spazio web su aruba...sto cercando di provare a configurare il mio guestbook prima di mettere online tutto il sito ovviamente ho poca esperienza con l'asp e i linguaggi lato server ....il database è access e sono sicuro di averlo inserito nella cartella giusta in ftp mbd-database,il percorso del database in questi script sembra essere diverso:mbddatabase url_DB = "driver={Microsoft Access Driver (*.mdb)};dbq=" & server.mappath("/mdbdatabase/
database.mdb") ho provato anche a mettere mdb-database,ma l'errore c'è sempre...su filezilla le cartelle e i file sono contenute in una cartella chiamate xxx.it (xxx ovviamente è il nome del sito)ho provato anche con con questo percorso "xxx.it/mdb-database/database.mdb" ma nulla continua a dare errori...ho creato nell'index 2 collegamenti html uno ad aggiungi.asp mi porta al form e mi da quest'errore quando lo compilo: Microsoft VBScript compilation error '800a0400' Expected statement /inserisci.asp, line 12 "′") ^ se vado su leggi guestbook mi da quest'errore Microsoft VBScript compilation error '800a0409' Unterminated string constant /guestbook.asp, line 23
url_DB = "driver={Microsoft Access Driver (*.mdb)};dbq=" & server.mappath("bellabianca.it/mdb-database/
l'altro collegamento lo ho aggiunto a index.asp e mi da il seguente errore Microsoft VBScript compilation error '800a03ea' Syntax error /index.asp, line 7
IF Lcase(Request.Form("username")) = Lcase(username) and
lo script è questo:
“guestbook.asp”. Si tratta di una pagina che preleva i messaggi inseriti nel database
e li visualizza, impaginandoli.
<html>
<head>
<title>MIO GUESTBOOK</title>
</head>
<body>
<p align="center"><font size="4" face="Verdana">Messaggi
GuestBook</font></p>
<%
' NUMERO DI MESSAGGI PER PAGINA
iPageSize = 5
If Request.QueryString("page") = "" Then
iPageCurrent = 1
Else
iPageCurrent = CInt(Request.QueryString("page"))
End If
If Request.QueryString("order") = "" Then
strOrderBy = "id"
Else
strOrderBy = Request.QueryString("order")
End If
' PERCORSO DEL DATABASE
url_DB = "driver={Microsoft Access Driver (*.mdb)};dbq=" & server.mappath("/mdbdatabase/
database.mdb")
Set Conn = Server.CreateObject("ADODB.Connection")
conn.Open url_DB
Set RS = Server.CreateObject("ADODB.Recordset")
' FA LA RICHIESTA AL DATABASE
sql = "SELECT * FROM GuestBook_Messaggi ORDER BY " & strOrderBy & " DESC;"
RS.Open sql, conn, adOpenKeyset
RS.PageSize = iPageSize
RS.CacheSize = iPageSize
iPageCount = RS.PageCount
If iPageCurrent > iPageCount Then iPageCurrent = iPageCount
If iPageCurrent < 1 Then iPageCurrent = 1
' NESSUN MESSAGGIO INSERITO -> VIENE VISUALIZZATO UN MESSAGGIO CHE
INFORMA CHE NON E' PRESENTE
' NEMMENO UN MESSAGGIO NEL GUESTBOOK
If iPageCount = 0 Then
%><hr>
<p align="center"><font size="2" face="Verdana">Nessun messaggio inserito
nel guestbook!</font></p>
<hr>
<%
Else
RS.AbsolutePage = iPageCurrent
iRecordsShown = 0
' SE I MESSAGGI SONO PRESENTI NEL GUESTBOOK, LI MOSTRA
Do While iRecordsShown < iPageSize And Not RS.EOF
%>
<hr>
<table border="0" cellpadding="0" cellspacing="0" width="64%">
<tr>
<td width="28%"><font face="Verdana" size="2">Titolo
Commento:</font></td>
<td width="72%"><font face="Verdana"
size="2"><%=RS("titolo")%></font></td>
</tr>
<tr>
<td width="28%"><font face="Verdana" size="2">Commento:</font></td>
<td width="72%"><font face="Verdana"
size="2"><%=RS("messaggio")%></font></td>
</tr>
<tr>
<td width="28%"><font face="Verdana" size="2">Autore:</font></td>
<td width="72%"><font face="Verdana" size="2">"><%=RS("autore")%></font></td>
</tr>
<tr>
<td width="28%"><font face="Verdana" size="2">Data
inserimento:</font></td>
<td width="72%"><font face="Verdana"
size="2"><%=RS("data")%></font></td>
</tr>
</table>
<hr>
<%
' COMPLETA LA VISUALIZZAZIONE DEI MESSAGGI E CHIUDE LA CONNESSIONE
' AL DATABASE
iRecordsShown = iRecordsShown + 1
RS.MoveNext
Loop
End If
RS.Close
Set RS = Nothing
Conn.Close
%><center>
<%
' MOSTRA IL NUMERO DELLE PAGINE,
' DATO CHE VERRANNO MOSTRATI
' IN QUESTO ESEMPIO 5 MESSAGGI PER PAGINA
For x=1 to iPageCount
%>
<font face="Verdana" size="2">[ <a
href="guestbook.asp?page=<%=x%>&order=<%= Server.URLEncode(strOrderBy)
%>"><%=x%></a> ]</font>
<%
next
%>
<p align="center"><font size="2" face="Verdana">Inserisci messaggio</font></p>
</body>
</html>
Pagine per inserire i messaggi
“aggiungi.asp”
<html>
<head>
<title>MIO GUESTBOOK</title>
</head>
<body>
<p align="center"><font size="4" face="Verdana">Aggiungi un Messaggio nel
GuestBook</font></p>
<form method="POST" action="inserisci.asp">
<table border="0" cellpadding="0" cellspacing="0" width="64%">
<tr>
<td width="28%"><font face="Verdana" size="2">Titolo
Commento:</font></td>
<td width="72%"><font face="Verdana" size="2"><input type="text"
name="titolo" size="20"></font></td>
</tr>
<tr>
<td width="28%"><font face="Verdana" size="2">Commento:</font></td>
<td width="72%"><font face="Verdana" size="2"><textarea rows="5"
name="commento" cols="36"></textarea></font></td>
</tr>
<tr>
<td width="28%"><font face="Verdana" size="2">Nome:</font></td>
<td width="72%"><font face="Verdana" size="2"><input type="text"
name="autore" size="20"></font></td>
</tr>
<tr>
<td width="28%"><font face="Verdana" size="2">Email:</font></td>
<td width="72%"><font face="Verdana" size="2"><input type="text"
name="email" size="20"></font></td>
</tr>
<tr>
<td width="100%" colspan="2"><input type="submit" value="Invia"
name="B1"><input type="reset" value="Reimposta" name="B2"></td>
</tr>
</table>
</form>
<p align="center"><font size="2" face="Verdana"><a
href="guestbook.asp">Leggi
GuestBook</a></font></p>
</body>
</html>
I dati inseriti verranno inviati alla pagina “inserisci.asp”:
<html>
<head>
<title>MIO GUESTBOOK</title>
</head>
<body>
<%
' RICHIEDE I CAMPI DAL FORM
titolo = Replace(Request.Form("titolo"), "'", "′")
' IMPOSTA L'INVIO A CAPO
'(RIMPIAZZA GLI INVII A CAPO NEL MESSAGGIO COL TAG HTML
), "'",
"′")
messaggio = Replace(Replace(Request.Form("commento"), chr(13), "
", 1) , "'",
"′")
autore = Replace(Request.Form("autore"), "'", "′")
email = Replace(Request.Form("email"), "'", "′")
data = Date()
' CONTROLLO CHE I CAMPI SIANO STATI COMPILATI CORRETTAMENTE
IF titolo = "" or messaggio = "" or autore = "" or Instr(email, "@") = 0 or Instr(email,
".") = 0 then
' UNO DEI CAMPI E' VUOTO
%>
<hr>
<p align="center"><font face="Verdana" size="3">Torna indietro e compila
tutti i campi correttamente!</font></p>
<hr>
<%
' ALTRIMENTI AGGIUNGE IL MESSAGGIO
else
' PERCORSO DEL DATABASE
url_DB = "driver={Microsoft Access Driver (*.mdb)};dbq=" & server.mappath("/mdbdatabase/
database.mdb")
Set Conn = Server.CreateObject("ADODB.Connection")
conn.Open url_DB
' APRE LA CONNESSIONE AL DATABASE
Set RecSet = Server.CreateObject("ADODB.Recordset")
SQL = "SELECT * FROM GuestBook_Messaggi"
RecSet.Open SQL, Conn, adOpenStatic, adLockOptimistic
' AGGIUNGE IL MESSAGGIO NEL DATABASE
Recset.Addnew
RecSet("titolo") = titolo
RecSet("messaggio") = messaggio
RecSet("autore") = autore
RecSet("email") = email
RecSet("data") = data
' AGGIORNA IL DATABASE, CHIUDE LA CONNESSIONE
' E PORTA L'UTENTE NEL GUESTBOOK
RecSet.Update
RecSet.Close
Conn.Close
Response.Redirect "guestbook.asp"
end if
%>
</body>
</html>
Creazione delle pagine per l’amministratore "index.asp"
<%
' CONTROLLA SE I DATI INSERITI NEL CAMPO DI LOGIN SONO ESATTI
' USERNAME AMMINISTRATORE
username = "admin"
' PASSWORD AMMINISTRATORE
password = "admin"
IF Lcase(Request.Form("username")) = Lcase(username) and
Lcase(Request.Form("password")) = Lcase(password) then
' I DATI SONO ESATTI E SI VIENE IDENTIFICATI COME AMMINISTRATORE
' E PORTATI NELLA PAGINA "GESTIONE_GUESTBOOK.ASP"
session("amministratore") = true
Response.Redirect "Gestione_GuestBook.asp"
End if
%>
<html>
<head>
<title>GESTIONE GUESTBOOK</title>
</head>
<body>
<p align="center"></p>
<p align="center"><font size="4" face="Verdana">Gestione
GuestBook!</font></p>
<form method="POST" action="index.asp">
<div align="center">
<center>
<table border="0" cellpadding="0" cellspacing="0" width="39%">
<tr>
<td width="50%"><font face="Verdana" size="2">Username:</font></td>
<td width="50%"><input type="text" name="username" size="20"></td>
</tr>
<tr>
<td width="50%"><font face="Verdana" size="2">Password:</font></td>
<td width="50%"><input type="password" name="password"
size="20"></td>
</tr>
<tr>
<td width="100%" colspan="2" height="5">
</td>
</tr>
<tr>
<td width="100%" colspan="2">
<p align="center"><input type="submit" value="Invia" name="B1"><input
type="reset" value="Reimposta" name="B2"></td>
Ecco la pagina “Gestione_GuestBook.asp”, in questa pagina vengono visualizzati i
messaggi del Guest Book e, cliccando sopra di essi, questi verranno eliminati dal
database:
<%
' CONTROLLA SE SI E' LOGGATI COME AMMINISTRATORE
IF Session("amministratore") <> True Then
Response.Redirect "index.asp"
End if
%>
<html>
<head>
<title>GESTIONE GUESBOOK</title>
</head>
<body>
<p align="left"><font size="4" face="Verdana">> Gestione
GuestBook!</font></p>
<%
' NUMERO DI MESSAGGI PER PAGINA
iPageSize = 20
If Request.QueryString("page") = "" Then
iPageCurrent = 1
Else
iPageCurrent = CInt(Request.QueryString("page"))
End If
If Request.QueryString("order") = "" Then
strOrderBy = "id"
Else
strOrderBy = Request.QueryString("order")
End If
' PERCORSO DEL DATABASE
url_DB = "driver={Microsoft Access Driver (*.mdb)};dbq=" & server.mappath("/mdbdatabase/
database.mdb")
Set Conn = Server.CreateObject("ADODB.Connection")
conn.Open url_DB
Set RS = Server.CreateObject("ADODB.Recordset")
' FA LA RICHIESTA AL DATABASE
sql = "SELECT * FROM GuestBook_Messaggi ORDER BY " & strOrderBy & " DESC;"
RS.Open sql, conn, adOpenKeyset
RS.PageSize = iPageSize
RS.CacheSize = iPageSize
iPageCount = RS.PageCount
If iPageCurrent > iPageCount Then iPageCurrent = iPageCount
If iPageCurrent < 1 Then iPageCurrent = 1
' SE E' ALMENO PRESENTE UN MESSAGGIO NEL GUESTBOOK:
If iPageCount > 0 Then
%>
<p align="left"><font face="Verdana" size="2">Ecco i messaggi inseriti, fai
click sopra il loro titolo per eliminarli:</font></p>
<table border="0" cellpadding="2" width="100%">
<tr>
<td width="2%" bgcolor="#C3D3DB"></td>
<td width="98%" bgcolor="#C3D3DB"><font face="Verdana" size="2">Titolo
Messaggio</font></td>
</tr>
<%
' MOSTRA TUTTI I MESSAGGI DEL GUESTBOOK
RS.AbsolutePage = iPageCurrent
iRecordsShown = 0
' SE I MESSAGGI SONO PRESENTI NEL GUESTBOOK, LI MOSTRA
Do While iRecordsShown < iPageSize And Not RS.EOF
%>
<tr>
<td width="2%"><font face="Verdana" size="2">></font></td>
<td width="98%"><font face="Verdana" size="2"></font></td>
</tr>
<%
iRecordsShown = iRecordsShown + 1
RS.MoveNext
Loop
RS.Close
Set RS = Nothing
%>
</table><center>
<%
' MOSTRA IL NUMERO DELLE PAGINE
' DATO CHE VERRANNO MOSTRATI
' IN QUESTO ESEMPIO 5 MESSAGGI PER PAGINA
For x=1 to iPageCount
%>
<font face="Verdana" size="2">[ <a
href="Gestione_Guestbook.asp?page=<%=x%>&order=<%=
Server.URLEncode(strOrderBy) %>"><%=x%></a> ]</font>
<%
Next
' NESSUN MESSAGGIO PRESENTE
Else
%>
<p align="left"><font face="Verdana" size="2">Nessun messaggio presente nel
guesbook!</font></p>
<%
End IF
%>
</body>
</html>
<%
' SE VIENE PASSATO UN VALORE DI ID MESSAGGIO GUESTBOOK
' E LA QUERYSTRING OPERAZIONE E' UGUALE A "ELIMINA"
' VIENE ELIMINATO IL MESSAGGIO SELEZIONATO
If Request.QueryString("operazione") = "elimina" and Request.QueryString("id")<>""
then
Set RecSet = Server.CreateObject("ADODB.Recordset")
' PRELEVA IL MESSAGGIO DAL DATABASE
SQL = "SELECT * FROM GuestBook_Messaggi where id = "&
Request.QueryString("id") &""
RecSet.Open SQL, Conn, adOpenStatic, adLockOptimistic
' CONTROLLA SE ESISTE E LO ELIMINA
If RecSet.Eof = False Then
RecSet.Delete
RecSet.Update
End IF
RecSet.Close
Conn.Close
Set RecSet = Nothing
Set Conn = Nothing
Response.Redirect "Gestione_GuestBook.asp"
End IF
%>
Ragazzi rinnovo le mie scuse per la troppa invadenza,pultroppo mi sono qui dalle 14 e non sono riuscito da solo a capire i problemi che da questo codice!!
Nell'attesa vi ringrazio tutti...