Announcement

Collapse
No announcement yet.

level access

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • level access

    Good morning, I have great difficulty with a query with the if condition.
    Users who access the management have a level of access, users with level 5 can only see their clients, instead users with likvello than 5 can see all customers for convenience place is the query that the error message

    SELECT
    clienti.ID,
    clienti.SOCIETA,
    clienti.COMMITTENTE,
    clienti.FILIALE,
    clienti.CONTRATTO,
    clienti.LOTTO,
    clienti.IDIMPORTAZIONE,
    clienti.DATAAFFIDO,
    clienti.DATASCADENZA,
    clienti.NOMINATIVO,
    clienti.CAPDEB,
    clienti.LOCALITADEB,
    clienti.PROVINCIADEB,
    clienti.TOTALEAFFIDATODEB,
    clienti.GESTORE,
    telefonate.IDCLI,
    telefonate.IDTELEFONATE,
    scarico.ESITO
    FROM
    clienti LEFT OUTER JOIN telefonate ON clienti.ID = telefonate.IDCLI
    LEFT OUTER JOIN scarico ON clienti.IDCLI = scarico.IDCLI
    WHERE (scarico.ESITO IS NULL OR scarico.ESITO = 'Parziale') AND (telefonate.IDTELEFONATE IS NULL) AND if ([liv] = 5) {
    clienti.GESTORE = [Nom]
    }

    Errore

    Errore durante l?accesso alla banca dati:
    You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '== 5) .gestore = ORIA GIAMPIERO}' at line 1
    select count(*) from clienti LEFT OUTER JOIN telefonate ON clienti.ID = telefonate.IDD LEFT OUTER JOIN scarico ON clienti.ID = scarico.IDD where (scarico.ESITO IS NULL OR scarico.ESITO = 'Parziale') AND (telefonate.IDTELEFONATE IS NULL) AND if (5 == 5) .gestore = ORIA GIAMPIERO}

  • #2
    why did you put the brackets here ? (red caracter)

    WHERE (scarico.ESITO IS NULL OR scarico.ESITO = 'Parziale') AND (telefonate.IDTELEFONATE IS NULL) AND if ([liv] = 5) {
    clienti.GESTORE = [Nom]
    }

    Comment


    • #3
      Shouldn't [liv] be between single quotes as [Nom] is?
      I.e. '[liv]'

      Comment


      • #4
        from research I found this result after the condition if the answer is inserted in the braces in the example I forgot to place; after the variable [Nom] even if it does not go the same meto

        Originally posted by cerelli View Post
        why did you put the brackets here ? (red caracter)

        WHERE (scarico.ESITO IS NULL OR scarico.ESITO = 'Parziale') AND (telefonate.IDTELEFONATE IS NULL) AND if ([liv] = 5) {
        clienti.GESTORE = [Nom]
        }

        Comment


        • #5
          variable [Liv] is numeric and [Nom] text I tried with the quotes but should not be the same

          Comment


          • #6
            But in the error:

            AND if (5 == 5) .gestore = ORIA GIAMPIERO}
            AND if (5 == 5) **********.gestore = ORIA GIAMPIERO}

            the name of table (clienti) are lost.

            Comment


            • #7
              sorry but I did not understand what you mean the name of the field is correct, however I think it is a syntax error in the construct of the query

              Comment


              • #8
                Originally posted by Giampiero View Post
                sorry but I did not understand what you mean the name of the field is correct, however I think it is a syntax error in the construct of the query
                What cerelli means is that in the sentence "AND if (5 == 5) .gestore", table name is missing. I mean..it should be tablename.gestore
                /Giuseppe

                Professional Scriptcase Services
                Some Customers opinions

                Comment


                • #9
                  I try to bypass the problem by working directly on the mask of the login but I have difficulty with wildcards to make all records instead what I did:
                  $usr = {User};
                  $pwd = {Password};

                  $sql = "SELECT
                  User,
                  psw,
                  CodiceDipendente,
                  Nominativo
                  FROM
                  tbldipendenti
                  WHERE
                  (User = '".$usr."') AND
                  (psw = '".$pwd."')";

                  sc_lookup(ds,$sql);
                  if (isset({ds[0][1]}))

                  {
                  [liv] ={ds[0][2]};
                  [Nom] ={ds[0][3]};
                  if ([liv] == 5)
                  {
                  [ter] ={ds[0][3]};
                  }
                  ELSE
                  [ter] = '%'; //here gives me the error

                  }
                  sc_apl_status('Menu','on');
                  sc_apl_status('Programma','on');
                  sc_apl_status('LottiAperti','on');
                  sc_apl_status('Iniziale','on');
                  sc_redir(Menu);
                  }
                  ELSE
                  {
                  echo"$usr";
                  }

                  Originally posted by Giu View Post
                  What cerelli means is that in the sentence "AND if (5 == 5) .gestore", table name is missing. I mean..it should be tablename.gestore

                  Comment

                  Working...
                  X