We need to make SQL selection over ODBC from a Windows 2003 server to a Windows 2012 server (I know 2003 is risk and unsupported)
I have installed the ODBC native SQL driver from Microsoft® SQL Server® 2008 R2 SP2 on the windows 2003 server. Configure and test the connection work.
In PHP I use:
$dsn = "stackoverflowdsn";
$user = "stackoverflow";
$pwd = "stackoverflow";
if (!$conn = odbc_connect($dsn, $user, $pwd))
{
echo "ODBC-Connection failed";
exit;
}
else {
if ($conn) {
$sql = "SELECT * FROM [DBNAME].[dbo].[Status];";
$rs = odbc_exec($conn, $sql);
while(odbc_fetch_row($rs)) {
$name = odbc_result($rs,"Name");
echo "name : $name <br>";
}
}
}
?>
The number of columns is correct but the result is a lot of trash:
name :
name : ãG
name : ãG
name : ãG
name : ãG
G
name : ãG
name : ãG
name : ãG
G¨
name : ãG
name : ãG
The chars changes sometimes
I set the compatibility of the 2012 Servers Database to SQL Server 2008 (100).
Can anyone can help me?