Visualizzazione dei risultati da 1 a 5 su 5
  1. #1
    Utente di HTML.it L'avatar di Lino80
    Registrato dal
    Oct 2005
    Messaggi
    1,560

    aiuto semplice INSERT INTO db, dov è l'errore?? :/

    posto il codice che interessa:

    codice:
    if instr(Intestazione,"Titolo") > 0 then
    			w_codice = ContenutoFile
    		end if
    		if instr(Intestazione,"Testo") > 0 then
    			w_Testo = ContenutoFile
    		end if
    if instr(Intestazione,"IMG") > 0 then
    			w_PFoto = ContenutoFile
    		end if
    
    On Error Resume Next
    	
    	If w_Codice = "" Then
    		Errore = Errore & "Codice prodotto
    "
    	Else
    		QSTitolo = Replace(w_Codice, "'", "''")
    	End If
    	If w_Testo = "" Then
    		Errore = Errore & "Nome prodotto
    "
    	Else
    		QSTesto = Replace(w_Testo, "'", "''")
    	End If
    	
    	
    	if w_PFoto<>"" then 
    		 QSIMG = "public/"&Replace(w_PFoto, "'", "''")	
    	else
    	   QSIMG=""	 	
    	end if	  
    
    	If QSID <> "" Then
    		SQL = "UPDATE News Set Titolo = '" & QSTitolo & "', IMG = '" & QSIMG & "', Testo = '" & QSTesto & "', Testolink = '" & QSTestolink & "', Link = '" & QSLink & "' WHERE ID = " & QSID
    	Else
    		SQL = "INSERT INTO News (Titolo, IMG, Testo, Testolink, Link) VALUES ('" & QSTitolo & "','" & QSIMG & "','"  & QSTesto & "','"  & QSTestolink & "','"  & QSLink & "')"
    	End If
    funziona tutto, il "Titolo" e l' "IMG" me lo scrive nel db, ma il "Testo" no
    il tipo dati nel db è uguale sia per Titolo che Testo!!

  2. #2
    dov'è che recuperi QSTestolink?
    IP-PBX management: http://www.easypbx.it

    Old account: 2126 messages
    Oldest account: 3559 messages

  3. #3
    Utente di HTML.it L'avatar di Lino80
    Registrato dal
    Oct 2005
    Messaggi
    1,560
    pagina form.asp

    codice:
    
    
    
    
    <%
    ' funzioni per far apparire l'immagine iniziale
    %>
    <script language="Javascript">
    
    <!--
    function preview() 
    {
      Img1= new Image(85,65)			  // definisco la dimensione dell' immagine iniziale
      Img1.src = "logo-iniziale.gif"      // path contenente l' immagine iniziale	
      
      Img2 = document.f.UPlFotop.value   // associo all' Img2 il contenuto che prelevo mediante
      									  // l' input type file nella form	
            
      document.swap.src = Img2;           // swappo l' immagine iniziale con quella caricata
      return true;
    }
      
    
    function previewg() 
    {
      Img3= new Image(150,150)			  // definisco la dimensione dell' immagine iniziale
      Img3.src = "logo-iniziale.gif"      // path contenente l' immagine iniziale	
      
      Img4 = document.f.UPlFotog.value   // associo all' Img2 il contenuto che prelevo mediante
      									  // l' input type file nella form	
            
      document.swapg.src = Img4;           // swappo l' immagine iniziale con quella caricata
      return true;	
    // -->
    }
    </SCRIPT>
    <%
    ' fine 
    %>
    
    <%
    	Dim QSID, QSIDProdotto, SQL, RS, Trovato, IMG, Titolo, Testo, Testolink, Link
    	QSID = Request.QueryString("ID")
    	QSIDProdotto = Request.QueryString("IDProdotto")
    	
    	If QSID <> "" Then
    		SQL = " SELECT * FROM News WHERE ID = " & QSID
    		Set RS = Conn.Execute(SQL)
    		If Not RS.EOF Then
    			Trovato = True
    			Titolo = RS("Titolo")
    			IMG = Replace(RS("IMG"), "public/", "")
    			Testo = RS("Testo")
    			Testolink = RS("Testolink")
    			Link = RS("Link")
    		Else
    			Trovato = false
    		End If
    		RS.close
    	Else
    		Trovato = False
    	End If
    %>	
    
    
    
    
    <p align="right">
    	">Indietro
    </p>
    
    <form name="f" method= "post" action= "update_news.asp" enctype="multipart/form-data">
    	          <table align="center" border="0" width="350">
                    <input type= "hidden" name= "ID" value="<%=QSID%>">
                    <tr> 
                      <td width="150" bgcolor="#FFFFEC">ID:</td>
                      <td width="200"><%=QSID%></td>
                    </tr>
                    <tr> 
                      <td bgcolor="#FFFFEC">Titolo:</td>
                      <td><input type= "text" name= "Titolo" value="<%=Titolo%>"></td>
                    </tr>
                    <tr>
    			<td bgcolor="#FFFFEC" valign="top">Nome foto piccola:</td>
    			<td><input type="text" size=30 name= "IMG" value="<%=IMG%>" maxlength=250></td>
    		</tr>
    		
    		<tr>
    			<td bgcolor="#FFFFEC" valign="top">Carica foto piccola:</td>
    			<td valign="top"><input type="file" size=30 name= "UPlFotop"  Onchange="preview()">
    
    			[img]logo-iniziale.gif[/img]			
    			</td>
    		</tr>
                    <tr> 
                      <td bgcolor="#FFFFEC">Descrizione:</td>
                      <td><textarea name= "Testo" cols="20" rows="5"><%=Testo%></textarea></td>
                    </tr>
                    <tr> 
                      <td bgcolor="#FFFFEC">Testo del link:</td>
                      <td><input type= "text" name= "Testolink" value="<%=Testolink%>"></td>
                    </tr>
                    <tr> 
                      <td bgcolor="#FFFFEC">link:</td>
                      <td><input type= "text" name= "Link" value="<%=Link%>"></td>
                    </tr>
                    <tr> 
                      <td align="right" colspan="2"><input type= "submit" name= "Go" value= "Invia"> 
                        </td>
                    </tr>
                  </table>		
    </form>
    
    
    <%
    	Set RS = Nothing
    	Conn.Close
    	Set Conn = Nothing
    %>
    pagina update.asp

    codice:
    
    
    
    
    <%
    	Dim QSID, QSTitolo, QSIMG, QSTesto, SQL, RS, QSTestolink, QSLink
    	dim w_ID, w_Cod_Old, w_codice, w_Prodotto, w_PDescrizione, w_GDescrizione, w_PFoto, w_GFoto 
    dim w_CPrezzo, w_RPrezzo, w_PuntiSconto, w_Iva, w_GiacenzaInfinita, w_Giacenza, w_Offerta
    dim w_Spedizione, w_SpeseSpedizione, w_Tipologia, w_Categorie
    dim percorso, ByteRicevuti, FileBinario, DatiRicevuti, FirmaFile, ArrPezzi, item, Inizio
    dim Intestazione, ContenutoFile, NomeUpload, NomeFile, Upload1, DimensioneFile1, EstensioneFile1, textStream, i, j
    dim FSO, NomeFile1, Upload2, DimensioneFile2, EstensioneFile2, NomeFile2, maxdimp, maxdimg, Home, Position, w_Home, w_Position, w_Testo
    	
    	'Questa variabile setta il percorso di dove effettuare l'upolad
    'la cartella non puo non esistere lo script non la crea ! ! !
    percorso = "/public/"
    maxdimp=50000    ' dimensione massima immagine piccola
    maxdimg=110000   ' dimensione massima immagine grande
    
    ByteRicevuti = Request.TotalBytes
    
    if ByteRicevuti > 0 then
    	DatiRicevuti = Request.BinaryRead(ByteRicevuti)
      FileBinario = RSBinaryToString(DatiRicevuti)	
    	FirmaFile = left(FileBinario,instr(FileBinario,"" & vbCrLf)-1)
    	ArrPezzi = split(FileBinario,FirmaFile)
    
    	for item = 1 to ubound(ArrPezzi)-1
    		Inizio = instr(ArrPezzi(item),"" & vbCrLf & "" & vbCrLf)
    		Intestazione = left(ArrPezzi(item),Inizio-1)
    		Inizio = Inizio + len("" & vbCrLf) + len("" & vbCrLf)
    	    	ContenutoFile = mid(ArrPezzi(item),Inizio,len(ArrPezzi(item))-Inizio-1)
    			
    			if instr(Intestazione,"Titolo") > 0 then
    			w_codice = ContenutoFile
    		end if
    		if instr(Intestazione,"Testo") > 0 then
    			w_Testo = ContenutoFile
    		end if
    			
    			' Recupero i campi se sono compilati
    		
    		if instr(Intestazione,"IMG") > 0 then
    			w_PFoto = ContenutoFile
    		end if
    		'if instr(Intestazione,"GFoto") > 0 then
    			'w_GFoto = ContenutoFile
    		'end if
    		
    			
    			' Qui recupero il file da uploadare (se presente) e lo scrivo
    		' sul server
    		if instr(Intestazione,"UPlFotop") > 0 then
    		  i = instr(Intestazione,"filename=")
    			j = instr(i + 10,Intestazione,chr(34))
    			NomeUpload = mid(Intestazione,i + 10,j-i-10)
    			i = instrRev(NomeUpload,"\")
    			NomeFile=""       ' max			
    			if i<>0 then
        	    NomeFile = mid(NomeUpload,i + 1)
        	else
        			NomeFile = NomeUpload
        	end if
    '     if i<>0 then			
          if NomeFile<>"" then
    				Set FSO = CreateObject("Scripting.FileSystemObject")
    				Upload1 = True
    				DimensioneFile1 = len(ContenutoFile)
    				if len(w_PFoto)=0 then
    					 NomeFile1 = NomeFile
    					 w_PFoto = NomeFile					 
     				else
     					 NomeFile1 = w_PFoto	
     				end if	 			
    				if DimensioneFile1 > maxdimp then
    					 Errore = Errore & "Dimensione immagine piccola ("&DimensioneFile1*0.001 & " kb)  maggiore del limite consentito ("&maxdimp*0.001 & " kb)
    "
    				else
    						EstensioneFile1 = LCase(right(NomeFile,4))				
    						if EstensioneFile1 <>".jpg" and EstensioneFile1 <>".gif" then
    							 Errore = Errore & "Tipo di file non corretto : "&EstensioneFile1&"
    "
    						else		 			
    								Set textStream = FSO.CreateTextFile(server.mappath(percorso & NomeFile1), True, False)
        						textStream.Write ContenutoFile
        						textStream.Close
        						Set textStream = Nothing
    						end if
    				end if	
    	   		Set FSO = Nothing
        	end if
    		end if
    
    		if instr(Intestazione,"UPlFotog") > 0 then
    		  i = instr(Intestazione,"filename=")
    			j = instr(i + 10,Intestazione,chr(34))
    			NomeUpload = mid(Intestazione,i + 10,j-i-10)
    			i = instrRev(NomeUpload,"\")
    			NomeFile=""       ' max			
    			if i<>0 then
    				 NomeFile = mid(NomeUpload,i + 1)
        	else
    					NomeFile = NomeUpload
        	end if
    '     if i<>0 then			
          if NomeFile<>"" then	
    				Set FSO = CreateObject("Scripting.FileSystemObject")
    				Upload2 = True
    				DimensioneFile2 = len(ContenutoFile)
    				if len(w_GFoto)=0 then
    					 NomeFile2 = NomeFile
    					 w_GFoto = NomeFile					 
     				else
     					 NomeFile2 = w_GFoto	
     				end if	 			
    				if DimensioneFile2 > maxdimg then
    					 Errore = Errore & "Dimensione immagine grande ("&DimensioneFile2*0.001 & " kb)  maggiore del limite consentito ("&maxdimg*0.001 & " kb)
    "
    				else
    						EstensioneFile2 = LCase(right(NomeFile,4))				
    						if EstensioneFile2 <>".jpg" and EstensioneFile2 <>".gif" then
    							 Errore = Errore & "Tipo di file non corretto : "&EstensioneFile2&"
    "
    						else		 			
    								Set textStream = FSO.CreateTextFile(server.mappath(percorso & NomeFile2), True, False)
        						textStream.Write ContenutoFile
        						textStream.Close
        						Set textStream = Nothing
    						end if
    				end if		
    	   		Set FSO = Nothing
        	end if
    		end if
    
    	next
    End if	
    			
    	Dim Cod_Old, Errore, Tipologia, Codice, Prodotto, PDescrizione, GDescrizione, PFoto, GFoto, CPrezzo, RPrezzo, PuntiSconto, IVA, GiacenzaInfinita, Giacenza, Offerta, Spedizione, SpeseSpedizione, SCategoria, Categoria, Categorie
    	On Error Resume Next
    	'QSID = w_ID
    	'Cod_Old = w_Cod_Old
    	If w_Codice = "" Then
    		Errore = Errore & "Codice prodotto
    "
    	Else
    		QSTitolo = Replace(w_Codice, "'", "''")
    	End If
    	If w_Testo = "" Then
    		Errore = Errore & "Nome prodotto
    "
    	Else
    		QSTesto = Replace(w_Testo, "'", "''")
    	End If
    	
    	'PDescrizione = Replace(w_PDescrizione, "'", "''")
    	'QSTestolink = Replace(w_GDescrizione, "'", "''")
    	'QSTesto = Replace(w_CPrezzo, "'", "''")
    	'Position = Replace(w_Position, "'", "''")
    	
    	if w_PFoto<>"" then 
    		 QSIMG = "public/"&Replace(w_PFoto, "'", "''")	
    	else
    	   QSIMG=""	 	
    	end if	  
    
    	If QSID <> "" Then
    		SQL = "UPDATE News Set Titolo = '" & QSTitolo & "', IMG = '" & QSIMG & "', Testo = '" & QSTesto & "', Testolink = '" & QSTestolink & "', Link = '" & QSLink & "' WHERE ID = " & QSID
    	Else
    		SQL = "INSERT INTO News (Titolo, IMG, Testo, Testolink, Link) VALUES ('" & QSTitolo & "','" & QSIMG & "','"  & QSTesto & "','"  & QSTestolink & "','"  & QSLink & "')"
    	End If
    
    	Set RS = Conn.Execute(SQL)
    	Set RS = Nothing
    	Conn.close
    	Set Conn = Nothing
    	If Err = 0 Then Response.Redirect "ok.asp"
    %>

  4. #4
    Utente di HTML.it L'avatar di Lino80
    Registrato dal
    Oct 2005
    Messaggi
    1,560
    Request object error 'ASP 0207 : 80004005'

    Cannot use Request.Form

    /update_news.asp, line 130

    Cannot use Request.Form collection after calling BinaryRead.

    codice:
    
    
    
    
    <%
    	'Dim QSID, QSTitolo, QSIMG, QSTesto, SQL, RS, QSTestolink, QSLink
    	dim w_ID, w_Cod_Old, w_codice, w_Prodotto, w_PDescrizione, w_GDescrizione, w_PFoto, w_GFoto 
    dim w_CPrezzo, w_RPrezzo, w_PuntiSconto, w_Iva, w_GiacenzaInfinita, w_Giacenza, w_Offerta
    dim w_Spedizione, w_SpeseSpedizione, w_Tipologia, w_Categorie
    dim percorso, ByteRicevuti, FileBinario, DatiRicevuti, FirmaFile, ArrPezzi, item, Inizio
    dim Intestazione, ContenutoFile, NomeUpload, NomeFile, Upload1, DimensioneFile1, EstensioneFile1, textStream, i, j
    dim FSO, NomeFile1, Upload2, DimensioneFile2, EstensioneFile2, NomeFile2, maxdimp, maxdimg, Home, Position, w_Home, w_Position, w_Testo
    	
    	'Questa variabile setta il percorso di dove effettuare l'upolad
    'la cartella non puo non esistere lo script non la crea ! ! !
    percorso = "/public/"
    maxdimp=50000    ' dimensione massima immagine piccola
    maxdimg=110000   ' dimensione massima immagine grande
    
    ByteRicevuti = Request.TotalBytes
    
    if ByteRicevuti > 0 then
    	DatiRicevuti = Request.BinaryRead(ByteRicevuti)
      FileBinario = RSBinaryToString(DatiRicevuti)	
    	FirmaFile = left(FileBinario,instr(FileBinario,"" & vbCrLf)-1)
    	ArrPezzi = split(FileBinario,FirmaFile)
    
    	for item = 1 to ubound(ArrPezzi)-1
    		Inizio = instr(ArrPezzi(item),"" & vbCrLf & "" & vbCrLf)
    		Intestazione = left(ArrPezzi(item),Inizio-1)
    		Inizio = Inizio + len("" & vbCrLf) + len("" & vbCrLf)
    	    	ContenutoFile = mid(ArrPezzi(item),Inizio,len(ArrPezzi(item))-Inizio-1)
    			
    			
    			
    			' Qui recupero il file da uploadare (se presente) e lo scrivo
    		' sul server
    		if instr(Intestazione,"UPlFotop") > 0 then
    		  i = instr(Intestazione,"filename=")
    			j = instr(i + 10,Intestazione,chr(34))
    			NomeUpload = mid(Intestazione,i + 10,j-i-10)
    			i = instrRev(NomeUpload,"\")
    			NomeFile=""       ' max			
    			if i<>0 then
        	    NomeFile = mid(NomeUpload,i + 1)
        	else
        			NomeFile = NomeUpload
        	end if
    '     if i<>0 then			
          if NomeFile<>"" then
    				Set FSO = CreateObject("Scripting.FileSystemObject")
    				Upload1 = True
    				DimensioneFile1 = len(ContenutoFile)
    				if len(w_PFoto)=0 then
    					 NomeFile1 = NomeFile
    					 w_PFoto = NomeFile					 
     				else
     					 NomeFile1 = w_PFoto	
     				end if	 			
    				if DimensioneFile1 > maxdimp then
    					 Errore = Errore & "Dimensione immagine piccola ("&DimensioneFile1*0.001 & " kb)  maggiore del limite consentito ("&maxdimp*0.001 & " kb)
    "
    				else
    						EstensioneFile1 = LCase(right(NomeFile,4))				
    						if EstensioneFile1 <>".jpg" and EstensioneFile1 <>".gif" then
    							 Errore = Errore & "Tipo di file non corretto : "&EstensioneFile1&"
    "
    						else		 			
    								Set textStream = FSO.CreateTextFile(server.mappath(percorso & NomeFile1), True, False)
        						textStream.Write ContenutoFile
        						textStream.Close
        						Set textStream = Nothing
    						end if
    				end if	
    	   		Set FSO = Nothing
        	end if
    		end if
    
    		if instr(Intestazione,"UPlFotog") > 0 then
    		  i = instr(Intestazione,"filename=")
    			j = instr(i + 10,Intestazione,chr(34))
    			NomeUpload = mid(Intestazione,i + 10,j-i-10)
    			i = instrRev(NomeUpload,"\")
    			NomeFile=""       ' max			
    			if i<>0 then
    				 NomeFile = mid(NomeUpload,i + 1)
        	else
    					NomeFile = NomeUpload
        	end if
    '     if i<>0 then			
          if NomeFile<>"" then	
    				Set FSO = CreateObject("Scripting.FileSystemObject")
    				Upload2 = True
    				DimensioneFile2 = len(ContenutoFile)
    				if len(w_GFoto)=0 then
    					 NomeFile2 = NomeFile
    					 w_GFoto = NomeFile					 
     				else
     					 NomeFile2 = w_GFoto	
     				end if	 			
    				if DimensioneFile2 > maxdimg then
    					 Errore = Errore & "Dimensione immagine grande ("&DimensioneFile2*0.001 & " kb)  maggiore del limite consentito ("&maxdimg*0.001 & " kb)
    "
    				else
    						EstensioneFile2 = LCase(right(NomeFile,4))				
    						if EstensioneFile2 <>".jpg" and EstensioneFile2 <>".gif" then
    							 Errore = Errore & "Tipo di file non corretto : "&EstensioneFile2&"
    "
    						else		 			
    								Set textStream = FSO.CreateTextFile(server.mappath(percorso & NomeFile2), True, False)
        						textStream.Write ContenutoFile
        						textStream.Close
        						Set textStream = Nothing
    						end if
    				end if		
    	   		Set FSO = Nothing
        	end if
    		end if
    
    	next
    End if	
    			
    
    	Dim QSID, QSTitolo, QSIMG, QSTesto, SQL, RS, QSTestolink, QSLink
    	'On Error Resume Next
    	QSID = Request.Form("ID")
    	QSTitolo = Replace(Request.Form("Titolo"), "'", "''")
    	QSIMG = Replace(Request.Form("IMG"), "'", "''")
    	QSTesto = Replace(Request.Form("Testo"), "'", "''")
    	QSTestolink = Replace(Request.Form("Testolink"), "'", "''")
    	QSLink = Replace(Request.Form("Link"), "'", "''")
    
    	If QSID <> "" Then
    		SQL = "UPDATE News Set Titolo = '" & QSTitolo & "', IMG = '" & QSIMG & "', Testo = '" & QSTesto & "', Testolink = '" & QSTestolink & "', Link = '" & QSLink & "' WHERE ID = " & QSID
    	Else
    		SQL = "INSERT INTO News (Titolo, IMG, Testo, Testolink, Link) VALUES ('" & QSTitolo & "','" & QSIMG & "','"  & QSTesto & "','"  & QSTestolink & "','"  & QSLink & "')"
    	End If
    
    	Set RS = Conn.Execute(SQL)
    	Set RS = Nothing
    	Conn.close
    	Set Conn = Nothing
    	If Err = 0 Then Response.Redirect "ok.asp"
    %>
    help

  5. #5
    Moderatore di ASP e MS Server L'avatar di Roby_72
    Registrato dal
    Aug 2001
    Messaggi
    19,559
    Quando usi l'upload non puoi usare request.form


    Roby

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 © 2025 vBulletin Solutions, Inc. All rights reserved.