My SQL query is not performed on an Access DB because of an accent

0

I am using ODBC to make queries in an Access Database along with php the problem is: I have a field in the BD with accent in this case the column is called contactode in it I have the option FLOOR , TELEPHONE and SERVICE when I make my query with FLOOR AND SERVICE there is no problem but when I want to ask for PHONE strong> does not work Any ideas (both in the code and in the BD are exactly the same with the accent) (I have Office 2016 if it influences something).

 <?php
 header('Content-Type: text/html; charset=UTF-8');
 # connect to a DSN "mydb" with a user and password 
 $connect4 = odbc_connect("proyecto", "usuario", "contra") or die("Error 
 Connect to Database");
 $query4 = "SELECT sum (IIF([contactode] = 'TELEFÓNICO',1,0))                 
            FROM datos 
            WEHRE datos.fecha_reg >= #$newDate1# and 
                datos.fecha_reg  <= #$newDate2# and 
                vendedor <> 'CASA' 
            GROUP BY vendedor
            ORDER BY vendedor";
 # perform the query4
 $result4 = odbc_exec($connect4, $query4);
 # fetch the data from the database
 while(odbc_fetch_row($result4)){
     $d1 = round ($d1 = odbc_result($result4, 1));  
     $sumatoria += $d1;  
     print("<tr><td>$d1</td></tr>");    
 }
 print("<td> $sumatoria</td>");
 # close the connection
 odbc_close($connect4);
 }
 ?>
    
asked by Juan Pablo Naranjo 20.06.2017 в 20:27
source

2 answers

1

You have to code what your query returns, in your question I do not see clearly where you bring the field in question, but it should be something like this:

$texto_codificado = utf8_encode($row['campotelefonico']);
    
answered by 20.06.2017 в 20:33
0

Thanks to those who helped me but I already solved the problem, converting the word TELEPHONE to "UTF-8" "Windows-1254" because with utf8_encode () it did not work that way:

<?php
header('Content-Type: text/html; charset=UTF-8');
# connect to a DSN "mydb" with a user and password 
$valor = iconv("UTF-8","Windows-1254",'TELEFÓNICO');
$connect4 = odbc_connect("proyecto", "usuario", "contra") or die("Error 
Connect to Database");
$query4 = "SELECT sum (IIF([contactode] = '$valor',1,0))                 
 FROM datos where datos.fecha_reg >= #$newDate1# and datos.fecha_reg  <= 
#$newDate2# and vendedor <> 'CASA' 
 GROUP BY vendedor
 ORDER BY vendedor";
 # perform the query3
$result4 = odbc_exec($connect4, $query4);
# fetch the data from the database
while(odbc_fetch_row($result4)){
 $d1 = round ($d1 = odbc_result($result4, 1));  
  $sumatoria += $d1;  
  print("<tr><td>$d1</td></tr>");   
}
print("<td> $sumatoria</td>");
# close the connection

odbc_close($connect4);
}
?>

An apology for the bad indentation.

    
answered by 21.06.2017 в 17:17