Skip to content
Advertisement

SQL-Server Select returning null on PHP

I have a query that returns all the data while running at MSSQL, but when I try to get the result with php code it returns null

SELECT:

   $query =  "SELECT  DISTINCT (E080SER.desser) as desser,
                E080SER.CODFAM codfam, e085cli.apecli apecli, 
                E085CLI.CODCLI codcli, E085CLI.NOMCLI nomeCli
                FROM
                E160CTR,
                E160CVS, e080ser,
                E085CLI,
                E070EMP,
                E070FIL
                WHERE
                e070emp.nomemp like '%Gestão tech%' and 
                e080ser.codser = e160cvs.codser and
                e080ser.codser like ('%manw%') and (E160CTR.CODEMP = 1)  and
                ((E160CTR.CODEMP = E070FIL.CODEMP) AND (E160CTR.CODFIL = 
                E070FIL.CODFIL) AND  
                (E160CTR.CODCLI = E085CLI.CODCLI) AND (E160CVS.CODEMP = 
                E160CTR.CODEMP) AND 
                (E160CVS.CODFIL = E160CTR.CODFIL) AND (E160CVS.NUMCTR = 
                E160CTR.NUMCTR)) AND
                (E160CTR.SITCTR = 'A') and e080ser.sitser = 'a' and 
                E080SER.CODEMP IN (1, 9)
                  order by e080ser.desser";

PHP CODE:

 $sql = sqlsrv_query($conn, $query);
 while($item = sqlsrv_fetch_array($sql)){
    var_dump($item);
}

Advertisement

Answer

I’ve found the problem

The problem was the encoding, I put the $query inside of utf8_encode(), and now it is returning the results.

Thank you all for your time.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement