Pagina 1 di 2 1 2 ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 13

Discussione: Expected '}' (errore)

  1. #1

    Expected '}' (errore)

    Lo script che segue è di un login:

    codice:
    <%@LANGUAGE = JScript%>
    
    <%
        var azione = new String(Request.QueryString("azione"));
    %>
    
    <%
        if (azione == "OK")
        {
            var username = new String(Request.Form("username"));
            var password = new String(Request.Form("password"));
            var username2 = username.replace(/'/g,"''");
            var password2 = password.replace(/'/g,"''");
            var Cn = new ActiveXObject("ADODB.Connection");
                Cn.Open("driver={Microsoft Access Driver (*.mdb)};dbq=" + Server.MapPath("../mdb-database/ilproverbio.mdb"));
            var Sql = "SELECT * FROM login WHERE name = '" + username2 + "' AND pass = '" + password2 + "'";
            var EseguiLogin = Cn.Execute(Sql);
                if (EseguiLogin.EOF)
                {
                    Cn.Close();
                    Response.Write("ACCESSO NEGATO");
                    Response.End;
                }
                else
                {
                    Cn.Close();
                    Session("username") = username;
                    with (Response)
                    {
                          Write("<p align='center'>");
                          Write("Benvenuto " + username + "!
    
    ");
                          Write("Ora puoi accedere a tutti i servizi
    ");
                          Write("Clicca qui!");
                          Write("</p>");
                    }
    
                }
        }
        else
        {
    %>

    Come mai mi da questo errore?

    Microsoft JScript compilation error '800a03f1'

    Expected '}'

    /login/login.asp, line 40
    Come va corretto?

    Grazie a tutti ciao
    La Gratitudine è la prima cosa nella vita...

    Grazie a tutti

  2. #2
    Utente di HTML.it L'avatar di Corwin
    Registrato dal
    Jan 2002
    Messaggi
    584
    codice:
        }
        else
        { }
    %>
    I don't wanna have to shout it out / I don't want my hair to fall out
    I don't wanna be filled with doubt / I don't wanna be a good boy scout
    I don't wanna have to learn to count / I don't wanna have the biggest amount
    I don't wanna grow up

  3. #3
    ora l'ho corretto, ma:

    questo è lo script corretto grazie a te:

    codice:
    <%@LANGUAGE = JScript%>
    
    <%
        var azione = new String(Request.QueryString("azione"));
    %>
    
    <%
        if (azione == "OK")
        {
            var username = new String(Request.Form("username"));
            var password = new String(Request.Form("password"));
            var username2 = username.replace(/'/g,"''");
            var password2 = password.replace(/'/g,"''");
            var Cn = new ActiveXObject("ADODB.Connection");
                Cn.Open("driver={Microsoft Access Driver (*.mdb)};dbq=" + Server.MapPath("../mdb-database/ilproverbio.mdb"));
            var Sql = "SELECT * FROM login WHERE name = '" + username2 + "' AND pass = '" + password2 + "'";
            var EseguiLogin = Cn.Execute(Sql);
                if (EseguiLogin.EOF)
                {
                    Cn.Close();
                    Response.Write("ACCESSO NEGATO");
                    Response.End;
                }
                else
                {
                    Cn.Close();
                    Session("username") = username;
                    with (Response)
                    {
                          Write("<p align='center'>");
                          Write("Entra nell'Amministrazione!");
                          Write("</p>");
                    }
    
                }
        }
        else
        { }
    %>
    questa è la pag html che invia i dati a quella di sopra:

    codice:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>Documento senza titolo</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>
    
    <body>
    <form action="login.asp" enctype="multipart/form-data" name="form1" target="_top">
      User 
      <input name="username" type="text" id="username" size="10">
      Psw 
      <input name="password" type="password" id="password" size="10">
      <input type="submit" name="Submit" value="Invia">
    </form>
    </body>
    </html>
    come mai se invio i dati mi da pag bianca?

    Grazie per il tuo aiuto
    La Gratitudine è la prima cosa nella vita...

    Grazie a tutti

  4. #4
    Utente di HTML.it L'avatar di Corwin
    Registrato dal
    Jan 2002
    Messaggi
    584
    Tu controlli che request.querystring("azione") sia uguale a "OK" ma nel form che usi non esiste un <input> che si chiami "azione"...
    I don't wanna have to shout it out / I don't want my hair to fall out
    I don't wanna be filled with doubt / I don't wanna be a good boy scout
    I don't wanna have to learn to count / I don't wanna have the biggest amount
    I don't wanna grow up

  5. #5
    e quindi, come posso sistemarlo?

    Grazie per il tuo aiuto
    La Gratitudine è la prima cosa nella vita...

    Grazie a tutti

  6. #6
    Così, è corretto??

    codice:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>Documento senza titolo</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>
    
    <body>
    <form action="login.asp" enctype="multipart/form-data" name="azione" target="_top">
      User 
      <input name="username" type="text" id="username" size="10">
      Psw 
      <input name="password" type="password" id="password" size="10">
      <input type="submit" name="azione" value="Invia">
    </form>
    </body>
    </html>
    La Gratitudine è la prima cosa nella vita...

    Grazie a tutti

  7. #7
    Utente di HTML.it L'avatar di Corwin
    Registrato dal
    Jan 2002
    Messaggi
    584
    se cambi la riga

    if (azione == "OK")

    con

    if (azione == "Invia")

    dovrebbe funzionare.
    I don't wanna have to shout it out / I don't want my hair to fall out
    I don't wanna be filled with doubt / I don't wanna be a good boy scout
    I don't wanna have to learn to count / I don't wanna have the biggest amount
    I don't wanna grow up

  8. #8
    io ho provato a risolvere così:

    codice:
    <%@LANGUAGE = JScript%>
    
    <%
        var azione = new String(Request.QueryString("azione"));
    %>
    
    <html>
     <head>
      <title>Login</title>
     </head>
    <body>
    <%
        if (azione == "OK")
        {
            var username = new String(Request.Form("username"));
            var password = new String(Request.Form("password"));
            var username2 = username.replace(/'/g,"''");
            var password2 = password.replace(/'/g,"''");
            var Cn = new ActiveXObject("ADODB.Connection");
          	Cn.Open("driver={Microsoft Access Driver (*.mdb)};dbq=" + Server.MapPath("../mdb-database/ilproverbio.mdb"));
    		var Sql = "SELECT * FROM e_blue_users WHERE uname = '" + username2 + "' AND pass = '" + password2 + "'";
            var EseguiLogin = Cn.Execute(Sql);
                if (EseguiLogin.EOF)
                {
                    Cn.Close();
                    Response.Write("ACCESSO NEGATO");
                    Response.End;
                }
                else
                {
                    Cn.Close();
                    Session("username") = username;
                    with (Response)
                    {
                          Write("<p align='center'>");
                          Write("Benvenuto " + username + "!
    
    ");
                          Write("Ora puoi accedere a tutti i servizi
    ");
                          Write("Clicca qui!");
                          Write("</p>");
                    }
    
                }
        }
        else
        {
    %>
    <form method="post" action="login.asp?azione=OK">
      <p align="center">[img]../img/login.gif[/img]
    
        <font color="#0000CC">Username</font>
    
        <input name="username" type="text" size="10">
        
    
        <font color="#0000CC">Password</font>
    
        <input name="password" type="password" size="10">
        
    
        <input type="submit" value="Login">
        <input type="reset" name="Submit" value="Cancella">
        
    
        <font color="#FF0000">Se non sei registrato
    
        Clicca Qui</font>
    </form>
    </p>
    <%        
        }
    %>
    </body>
    </html>
    ma mi da questo errore:

    Server.MapPath() error 'ASP 0175 : 80004005'

    Disallowed Path Characters

    /login/login.asp, line 20

    The '..' characters are not allowed in the Path parameter for the MapPath method.
    penso sia un errore nella stringa di connessione?

    Che ne pensi?

    Grazie, sei gentilissimo
    La Gratitudine è la prima cosa nella vita...

    Grazie a tutti

  9. #9
    up
    La Gratitudine è la prima cosa nella vita...

    Grazie a tutti

  10. #10
    Utente di HTML.it L'avatar di Corwin
    Registrato dal
    Jan 2002
    Messaggi
    584
    Probabilmente sei in hosting su win 2003 che impedisce l'uso di ../ con server.mappath e con gli include.

    Prova a vedere se riesci a ricostruire il percorso al database con

    codice:
    var percorso = Request.ServerVariables("APPL_PHYSICAL_PATH") + "mdb-database\ilproverbio.mdb";
    e poi

    codice:
    Cn.Open("driver={Microsoft Access Driver (*.mdb)};dbq=" + percorso));
    I don't wanna have to shout it out / I don't want my hair to fall out
    I don't wanna be filled with doubt / I don't wanna be a good boy scout
    I don't wanna have to learn to count / I don't wanna have the biggest amount
    I don't wanna grow up

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.