I can not access the MS SQL SERVER database using PDO. I've done everything, the best answer I got was with the code below, but I keep getting an error response:
Connection Error SQLSTATE [] (null) (severity 0)
My server is CentOS 5.11 (64 bit)
Any ideas?
<?php
try {
$hostname = "db-gadel-campinas.lexos.com.br,1500";
$dbname = "LexManager_GadelCampinas";
$username = "gadelview";
$pw = "password";
$pdo = new PDO ('dblib:host=$hostname;dbname=$dbname', '$username', '$pw');
} catch (PDOException $e) {
echo "Erro de Conexão " . $e->getMessage() . "\n";
exit;
}
?>
I changed the code and the connection to sqlserver seems to work. Now it's figuring out how to query the table and show the data :). Any tips?
Is the code correct?
<?php
try {
$hostname = "db-gadel-campinas.lexos.com.br";
$port = 1500;
$dbname = "LexManager_GadelCampinas";
$username = "gadelview";
$pw = "password";
$dbh = new PDO ("dblib:host=$hostname:$port;dbname=$dbname","$username","$pw");
echo "Conexão ok";
} catch (PDOException $e) {
echo "Failed to get DB handle: " . $e->getMessage() . "\n";
exit;
}
?>