Visualizzazione dei risultati da 1 a 8 su 8
  1. #1
    Utente di HTML.it
    Registrato dal
    Sep 2004
    Messaggi
    157

    Proprietà charset in pagina ASP e collation in mySQL.

    Descrizione del problema
    Ho un database mySQL su Aruba e un sito in ASP che interagisce con tale DB.
    Quando inserisco delle informazioni nel DB tramite apposito modulo del sito ASP, le lettere accentate, il simbolo €, ° e altri caratteri speciali vengono sostituiti con lettere strane di altro alfabeto (per es. è).

    Azioni intraprese (vane)
    Siccome nel DB mySQL la proprietà COLLATION del campo della tabella è impostato su latin1_swedish_ci (ma ho provato anche con le codifiche UTF8 ma non ho risolto) ho impostato una per volta la seguente riga nella pagina ASP nei modi qui di seguito indicati:
    codice:
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    poi

    codice:
    <meta http-equiv="Content-Type" content="text/html; charset=Latin1"/>
    (sperando che si scriva "Latin1" e non "Latin-1" o altro...)
    e infine

    codice:
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8559-1"/>
    Ma sembra che la pagina ASP nello scrivere nel DB mySQL parli una lingua diversa da quella del DB.

    Domanda
    Cosa devo fare affinchè le pagine ASP scrivano correttamente le lettere accentate e i simboli nel DB mySQL?

    Grazie infinite a chi mi aiuterà (ci sono dietro da un mese!).

  2. #2
    Utente di HTML.it L'avatar di agenti
    Registrato dal
    Feb 2002
    Messaggi
    2,427
    come inserisci i valori nel database ?

  3. #3
    Utente di HTML.it
    Registrato dal
    Sep 2004
    Messaggi
    157
    Ecco il link alla pagina annunciadd.asp, che alla riga 1329 e seguenti ha la funzione di aggiunta del nuovo record: annunciadd.asp

    Grazie.

  4. #4
    Utente di HTML.it L'avatar di agenti
    Registrato dal
    Feb 2002
    Messaggi
    2,427
    e secondo te apriamo uno zip da uno sconosciuto ????
    :quote:

    passa il codice..

  5. #5
    Utente di HTML.it
    Registrato dal
    Sep 2004
    Messaggi
    157
    Scusa tanto! Sono iscritto dal 2004, ho 150 post.... credi che voglia spedire virus agli utenti di questo forum?
    Allora posto il link alla pagina ASP direttamente.... perchè il codice è veramente lungo da incollare qui! VVoVe:

    annunciadd.asp

    Se questo non è sufficiente.... dimmelo.

    Grazie ancora.
    Ciao.

  6. #6
    incolla solo il codice della pagina che interessa...
    IP-PBX management: http://www.easypbx.it

    Old account: 2126 messages
    Oldest account: 3559 messages

  7. #7
    Utente di HTML.it
    Registrato dal
    Sep 2004
    Messaggi
    157
    Alla riga 1329 e seguenti c'è il blocco che riguarda l'aggiunta di record.
    Nel resto c'è il form con validazione del contenuto.

    Come preannunciato, è un po' lunghetto e quindi non mi accetta tutto... metto qui solo il blocco che riguarda l'aggiunta di record.

    codice:
    ' Add record
    Function AddRow()
    	On Error Resume Next
    	Dim rs, sSql, sFilter
    	Dim rsnew
    	Dim bCheckKey, sSqlChk, sWhereChk, rsChk
    	Dim bInsertRow
    
    	' Check for duplicate key
    	bCheckKey = True
    	sFilter = annunci.SqlKeyFilter
    	If annunci.idappartamenti.CurrentValue = "" Or IsNull(annunci.idappartamenti.CurrentValue) Then
    		bCheckKey = False
    	Else
    		sFilter = Replace(sFilter, "@idappartamenti@", ew_AdjustSql(annunci.idappartamenti.CurrentValue)) ' Replace key value
    	End If
    	If Not IsNumeric(annunci.idappartamenti.CurrentValue) Then
    		bCheckKey = False
    	End If
    	If bCheckKey Then
    		Set rsChk = annunci.LoadRs(sFilter)
    		If Not (rsChk Is Nothing) Then
    			Session(EW_SESSION_MESSAGE) = "Duplicate value for primary key"
    			rsChk.Close
    			Set rsChk = Nothing
    			AddRow = False
    			Exit Function
    		End If
    	End If
    
    	' Add new record
    	sFilter = "(0 = 1)"
    	annunci.CurrentFilter = sFilter
    	sSql = annunci.SQL
    	Set rs = Server.CreateObject("ADODB.Recordset")
    	rs.CursorLocation = EW_CURSORLOCATION
    	rs.Open sSql, conn, 1, 2
    	rs.AddNew
    	If Err.Number <> 0 Then
    		Session(EW_SESSION_MESSAGE) = Err.Description
    		rs.Close
    		Set rs = Nothing
    		AddRow = False
    		Exit Function
    	End If
    
    	' Field categoria
    	Call annunci.categoria.SetDbValue(annunci.categoria.CurrentValue, Null)
    	rs("categoria") = annunci.categoria.DbValue
    
    	' Field contatto
    	Call annunci.contatto.SetDbValue(annunci.contatto.CurrentValue, Null)
    	rs("contatto") = annunci.contatto.DbValue
    
    	' Field email
    	Call annunci.email.SetDbValue(annunci.email.CurrentValue, Null)
    	rs("email") = annunci.email.DbValue
    
    	' Field telefono
    	Call annunci.telefono.SetDbValue(annunci.telefono.CurrentValue, Null)
    	rs("telefono") = annunci.telefono.DbValue
    
    	' Field cellulare
    	Call annunci.cellulare.SetDbValue(annunci.cellulare.CurrentValue, Null)
    	rs("cellulare") = annunci.cellulare.DbValue
    
    	' Field idregione
    	Call annunci.idregione.SetDbValue(annunci.idregione.CurrentValue, Null)
    	rs("idregione") = annunci.idregione.DbValue
    
    	' Field idprovincia
    	Call annunci.idprovincia.SetDbValue(annunci.idprovincia.CurrentValue, Null)
    	rs("idprovincia") = annunci.idprovincia.DbValue
    
    	' Field idcomune
    	Call annunci.idcomune.SetDbValue(annunci.idcomune.CurrentValue, Null)
    	rs("idcomune") = annunci.idcomune.DbValue
    
    	' Field localita
    	Call annunci.localita.SetDbValue(annunci.localita.CurrentValue, Null)
    	rs("localita") = annunci.localita.DbValue
    
    	' Field indirizzo
    	Call annunci.indirizzo.SetDbValue(annunci.indirizzo.CurrentValue, Null)
    	rs("indirizzo") = annunci.indirizzo.DbValue
    
    	' Field cameredaletto
    	Call annunci.cameredaletto.SetDbValue(annunci.cameredaletto.CurrentValue, Null)
    	rs("cameredaletto") = annunci.cameredaletto.DbValue
    
    	' Field bagni
    	Call annunci.bagni.SetDbValue(annunci.bagni.CurrentValue, Null)
    	rs("bagni") = annunci.bagni.DbValue
    
    	' Field metriquadrati
    	Call annunci.metriquadrati.SetDbValue(annunci.metriquadrati.CurrentValue, Null)
    	rs("metriquadrati") = annunci.metriquadrati.DbValue
    
    	' Field postoauto
    	Call annunci.postoauto.SetDbValue(annunci.postoauto.CurrentValue, Null)
    	rs("postoauto") = annunci.postoauto.DbValue
    
    	' Field garage
    	Call annunci.garage.SetDbValue(annunci.garage.CurrentValue, Null)
    	rs("garage") = annunci.garage.DbValue
    
    	' Field giardino
    	Call annunci.giardino.SetDbValue(annunci.giardino.CurrentValue, Null)
    	rs("giardino") = annunci.giardino.DbValue
    
    	' Field piscina
    	Call annunci.piscina.SetDbValue(annunci.piscina.CurrentValue, Null)
    	rs("piscina") = annunci.piscina.DbValue
    
    	' Field ascensore
    	Call annunci.ascensore.SetDbValue(annunci.ascensore.CurrentValue, Null)
    	rs("ascensore") = annunci.ascensore.DbValue
    
    	' Field piano
    	Call annunci.piano.SetDbValue(annunci.piano.CurrentValue, Null)
    	rs("piano") = annunci.piano.DbValue
    
    	' Field tot_piani
    	Call annunci.tot_piani.SetDbValue(annunci.tot_piani.CurrentValue, Null)
    	rs("tot_piani") = annunci.tot_piani.DbValue
    
    	' Field veranda
    	Call annunci.veranda.SetDbValue(annunci.veranda.CurrentValue, Null)
    	rs("veranda") = annunci.veranda.DbValue
    
    	' Field descrizione
    	Call annunci.descrizione.SetDbValue(annunci.descrizione.CurrentValue, Null)
    	rs("descrizione") = annunci.descrizione.DbValue
    
    	' Field IP
    	annunci.IP.DbValue = ew_CurrentUserIP
    	rs("IP") = annunci.IP.DbValue
    
    	' Field data
    	annunci.data.DbValue = ew_CurrentDate
    	rs("data") = annunci.data.DbValue
    
    	' Field foto1
    	Call annunci.foto1.Upload.SaveToSession() ' Save file value to Session
    	annunci.foto1.Upload.DbValue = rs("foto1") ' Get original value
    	If IsNull(annunci.foto1.Upload.Value) Then
    		rs("foto1") = Null
    	Else
    		rs("foto1") = ew_UploadFileNameEx(ew_UploadPathEx(True, "public/"), annunci.foto1.Upload.FileName)
    	End If
    
    	' Field foto2
    	Call annunci.foto2.Upload.SaveToSession() ' Save file value to Session
    	annunci.foto2.Upload.DbValue = rs("foto2") ' Get original value
    	If IsNull(annunci.foto2.Upload.Value) Then
    		rs("foto2") = Null
    	Else
    		rs("foto2") = ew_UploadFileNameEx(ew_UploadPathEx(True, "public/"), annunci.foto2.Upload.FileName)
    	End If
    
    	' Field foto3
    	Call annunci.foto3.Upload.SaveToSession() ' Save file value to Session
    	annunci.foto3.Upload.DbValue = rs("foto3") ' Get original value
    	If IsNull(annunci.foto3.Upload.Value) Then
    		rs("foto3") = Null
    	Else
    		rs("foto3") = ew_UploadFileNameEx(ew_UploadPathEx(True, "public/"), annunci.foto3.Upload.FileName)
    	End If
    
    	' Field num_locali
    	Call annunci.num_locali.SetDbValue(annunci.num_locali.CurrentValue, Null)
    	rs("num_locali") = annunci.num_locali.DbValue
    
    	' Field idtipoimmobile
    	Call annunci.idtipoimmobile.SetDbValue(annunci.idtipoimmobile.CurrentValue, Null)
    	rs("idtipoimmobile") = annunci.idtipoimmobile.DbValue
    
    	' Field balcone
    	Call annunci.balcone.SetDbValue(annunci.balcone.CurrentValue, Null)
    	rs("balcone") = annunci.balcone.DbValue
    
    	' Field condizioni
    	Call annunci.condizioni.SetDbValue(annunci.condizioni.CurrentValue, Null)
    	rs("condizioni") = annunci.condizioni.DbValue
    
    	' Field prezzo
    	Call annunci.prezzo.SetDbValue(annunci.prezzo.CurrentValue, Null)
    	rs("prezzo") = annunci.prezzo.DbValue
    
    	' Field annocostruzione
    	Call annunci.annocostruzione.SetDbValue(annunci.annocostruzione.CurrentValue, Null)
    	rs("annocostruzione") = annunci.annocostruzione.DbValue
    
    	' Check recordset update error
    	If Err.Number <> 0 Then
    		Session(EW_SESSION_MESSAGE) = Err.Description
    		rs.Close
    		Set rs = Nothing
    		AddRow = False
    		Exit Function
    	End If
    
    	' Call Row Inserting event
    	bInsertRow = annunci.Row_Inserting(rs)
    	If bInsertRow Then
    
    		' Field foto1
    		If Not IsNull(annunci.foto1.Upload.Value) Then Call ew_SaveFile(ew_UploadPathEx(True, "public/"), rs("foto1"), annunci.foto1.Upload.Value)
    
    		' Field foto2
    		If Not IsNull(annunci.foto2.Upload.Value) Then Call ew_SaveFile(ew_UploadPathEx(True, "public/"), rs("foto2"), annunci.foto2.Upload.Value)
    
    		' Field foto3
    		If Not IsNull(annunci.foto3.Upload.Value) Then Call ew_SaveFile(ew_UploadPathEx(True, "public/"), rs("foto3"), annunci.foto3.Upload.Value)
    
    		' Clone new rs object
    		Set rsnew = ew_CloneRs(rs)
    		rs.Update
    		If Err.Number <> 0 Then
    			Session(EW_SESSION_MESSAGE) = Err.Description
    			AddRow = False
    		Else
    			AddRow = True
    		End If
    	Else
    		rs.CancelUpdate
    		If annunci.CancelMessage <> "" Then
    			Session(EW_SESSION_MESSAGE) = annunci.CancelMessage
    			annunci.CancelMessage = ""
    		Else
    			Session(EW_SESSION_MESSAGE) = "Insert cancelled"
    		End If
    		AddRow = False
    	End If
    	rs.Close
    	Set rs = Nothing
    	If AddRow Then
    		annunci.idappartamenti.DbValue = rsnew("idappartamenti")
    
    		' Call Row Inserted event
    		Call annunci.Row_Inserted(rsnew)
    	End If
    
    	' Field foto1
    	Call annunci.foto1.Upload.RemoveFromSession() ' Remove file value from Session
    
    	' Field foto2
    	Call annunci.foto2.Upload.RemoveFromSession() ' Remove file value from Session
    
    	' Field foto3
    	Call annunci.foto3.Upload.RemoveFromSession() ' Remove file value from Session
    	If IsObject(rsnew) Then
    		rsnew.Close
    		Set rsnew = Nothing
    	End If
    End Function
    %>
    Spero che questo pezzo di codice sia sufficiente a capire dov'è il problema.

  8. #8
    Utente di HTML.it L'avatar di agenti
    Registrato dal
    Feb 2002
    Messaggi
    2,427
    prova ad usare una funzione di codifica..

    Function HTMLDecode(sText)
    if len(sText) > 0 then
    Dim I
    sText = Replace(sText, "&quot;", Chr(34))
    sText = Replace(sText, "&lt;" , Chr(60))
    sText = Replace(sText, "&gt;" , Chr(62))
    sText = Replace(sText, "&amp;" , Chr(38))
    sText = Replace(sText, "", Chr(32))
    For I = 1 to 255
    sText = Replace(sText, "&#" & I & ";", Chr(I))
    Next
    HTMLDecode = sText
    else
    HTMLDecode = "Nessuna nota"
    end if
    End Function

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2026 vBulletin Solutions, Inc. All rights reserved.