Pagina 1 di 6 1 2 3 ... ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 53

Discussione: query che non va

  1. #1

    query che non va

    salve sto cercando di imparare come usare mysql, con scarsi risultati devo dire, ho un file che dovrebbe prendere i dati da un form, ma l'unica cosa che fa è stamparmi a video la query con l'username che ho usato, questo è il codice
    <%@LANGUAGE="VBSCRIPT"%>


    <HTML>
    <HEAD>
    <TITLE>Verifica / Memorizzazione dati</TITLE>
    </HEAD>
    <BODY>
    <%
    ' Dichiarazione variabili
    dim intTest
    intTest="0"
    ' Verifico se manca il nome utente
    if request.form("username")="" then
    response.redirect "Registra.asp?Id=2"
    end if
    ' Verifico se manca la password
    if request.form("password")="" then
    response.redirect "Registra.asp?Id=3"
    end if

    ' Apro il database

    call OpenConwrite

    '' cambio controllo esistenza




    if Esiste ("Utenti", "username='"&request.form("username")&"'" ) Then 'rs.eof then
    'NON è presente, memorizzo
    ' inserimento dati

    call openrstWrite("Select * from Utenti")
    rst.addnew
    rst("username")=request.form("username")
    rst("password")=request.form("password")
    rst("email")=request.form("email")
    rst("schieramento")=request.form("schieramento")
    rst("razza")=request.form("razza")
    rst("sesso")=request.form("sesso")
    rst("data")=date
    rst.update
    call closerst
    else
    intTest="1"
    end if

    Call closecon
    'avvviso ke il nome è già presente
    if intTest="1" then
    response.redirect "Registra.asp?Id=1"
    else
    response.redirect "registrato.asp"
    end if
    %>
    </BODY>
    </HTML>

    qualcuno sa dirmi dove sbaglio?

  2. #2
    poste anche il file include connection.asp
    se non è bello ciò che è bello figuriamoci ciò che è brutto!!



    fai anche tu come me: indenta il codice!!!!

  3. #3
    eccolo:
    <%
    Session("Debug")= false
    Dim con
    Dim rst
    Dim cmd
    Dim ErrorMsg
    Dim OkMsg
    Dim ConnectionString

    Sub OpenCon
    Set con = Server.CreateObject("ADODB.Connection")

    'ConnectionString = "DSN=NomeDSN;UID=user;PWD=password;"
    ConnectionString = "DSN=locale;UID=root;PWD=;"
    End Sub


    Sub OpenConWrite
    OpenCon
    con.Open ConnectionString
    End Sub

    Sub OpenConRead
    OpenCon
    con.Mode = 1
    con.Open ConnectionString
    End Sub

    Function OpenConCommand(strSqlQuery)
    con.Execute strSqlQuery,n
    OpenConCommand = n
    End Function


    Sub CloseCon
    If not isempty(con) then
    If not (con is nothing) then
    if con.State = 1 then con.Close
    End If
    End If
    set con = nothing
    End Sub

    Sub OpenRst(strSqlQuery)
    Set rst = Server.CreateObject("ADODB.recordset")
    rst.CursorLocation = 3
    response.Write strSqlQuery
    response.End


    rst.Open strSqlQuery,con,0,1
    End Sub

    Sub OpenRstWrite(strSqlQuery)
    Set rst = Server.CreateObject("ADODB.recordset")
    rst.CursorLocation = 3
    rst.Open strSqlQuery,con,2,2
    End Sub

    Sub CloseRst
    if not isempty(rst) then
    if not (rst is nothing) then
    if rst.State = 1 then rst.Close
    End If
    End If
    set rst = nothing
    End Sub

    Sub OpenCmd(strSqlCommandText)
    set cmd = Server.CreateObject("ADODB.Command")
    set cmd.ActiveConnection = con
    cmd.CommandText = strSqlCommandText
    End Sub

    Sub CloseCmd
    set cmd = nothing
    End Sub

    Public Function EmptyRecordset()
    If Not rst.BOF And Not rst.EOF Then
    EmptyRecordset = False
    Else
    EmptyRecordset = True
    End If
    End Function


    '-----------------------------------------------------------------------------'
    ' Funzione Esiste (tabella,condizione)
    ' Restituisce un valore booleano TRUE se c'è almeno un record che corrisponde alla condizione
    ' altrimenti restituisce false
    '-----------------------------------------------------------------------------'

    Public Function Esiste (tabella,condizione)
    strSqlQuery = "select * from " & utenti & " where " & condizione

    'response.Write strSqlQuery
    ' response.End
    call OpenRst(strSqlQuery)
    if EmptyRecordset() then
    flg = false
    else
    flg = true
    end if
    closerst
    Esiste = flg


    End Function

    '-----------------------------------------------------------------------------'
    ' Funzione GetArrayRes (strSqlQuery)
    ' Restituisce un array ricavato dal recorset o una stringa vuota nel caso
    ' il recordset fosse vuoto

    '-----------------------------------------------------------------------------'
    Public Function GetArrayRes (strSqlQuery)
    call OpenRst(strSqlQuery)
    if EmptyRecordset() then
    flg = ""
    else
    flg = rst.Getrows()
    end if
    closerst
    GetArrayRes = flg


    End Function

    '-----------------------------------------------------------------------------'
    ' Funzione GetScalare (strSqlQuery,vdefault)
    ' Restituisce uno scalare nella psizione 0,0 dell'array ricavato dal recorset
    ' o il valore di default
    '-----------------------------------------------------------------------------'
    Public Function GetScalare (strSqlQuery, vdefault)
    arr_tmp = getArrayRes(strSqlQuery)
    if isarray(arr_tmp) then
    flg = arr_tmp(0,0)
    else
    flg = vdefault
    end if
    GetScalare = flg
    End Function


    'Funzione per compilare record in tabella generica
    sub InserisciCampi(tabella,listacampi,listavalori)
    call openRstWrite("select * from "&utenti&" ")
    arr_lista_campi= split(listacampi,"|")
    arr_lista_valori= split(listavalori,"|")

    response.write listacampi
    rst.AddNew
    for i= 0 to ubound(arr_lista_campi)
    if arr_lista_valori(i) = "XXX_NOW" then
    rst(arr_lista_campi(i)) = now()
    else
    rst(arr_lista_campi(i)) = arr_lista_valori(i)
    end if
    next
    rst.Update

    closerst

    End sub


    'recupera il prossimo numero disponibile
    ' (Da mettere sotto transazione con blocco numero)
    Function GetMaxElement(campo,tabella)

    sql = "select max("&campo&") as usrnum from "&tabella&""
    openrst(sql)

    if Emptyrecordset then
    nuovoUtente = 1
    else
    if isvarnull(rst("usrnum")) then
    nuovoUtente = 1
    else
    nuovoUtente = rst("usrnum") + 1
    end if
    end if
    closerst
    GetMaxElement = nuovoUtente
    End Function

    %>
    grassie

  4. #4
    nessuno mi aiuta?

  5. #5
    vi prego non riesco piu ad andare avanti

  6. #6
    Moderatore di ASP e MS Server L'avatar di Roby_72
    Registrato dal
    Aug 2001
    Messaggi
    19,559
    Se posti 6 km di codice nessuno lo leggerà mai! :rollo:
    Che errore ti da? Dove? A che riga?

    Roby

  7. #7
    per quanto riguarda il codice mi è stato detto di postarlo scusa, per l'errore non mi da nessun errore, solo che quando finisco la registrazione e clicco sul pulsante che permette la registrazione mi restituisce a video questo messaggio

    select * from where username='nome'
    dove per nome compare il nome che ho usato per la registrazione
    sto uscendo pazzo, gia ci capisco poco

  8. #8
    Moderatore di ASP e MS Server L'avatar di Roby_72
    Registrato dal
    Aug 2001
    Messaggi
    19,559
    Il 97% di quello che hai scritto non ti serve a nulla.
    Detto questo devi togliere queste due rghe che non so perché hai messo:

    response.Write strSqlQuery
    response.End


    Roby

  9. #9
    fatto l'errore che mi da ora è questo
    Tipo di errore:
    Errore di run-time di Microsoft VBScript (0x800A01FB)
    Si è verificata un'eccezione: 'rst.Open'
    /Terzaera/connection.asp, line 51
    dove la linea 51 è
    rst.Open strSqlQuery,con,0,1

  10. #10
    Moderatore di ASP e MS Server L'avatar di Roby_72
    Registrato dal
    Aug 2001
    Messaggi
    19,559
    Bella domanda... VVoVe:

    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.