I have connected the sql database server using FreeTDS in php. I am trying to execute sql select query in php. I can't able to execute query. I mentioned the program below
<?php
$empid = 10068;
try
{
$db = new PDO('odbc:Driver=FreeTDS; Server=XXXXXXX; Port=1433; Database=XXXX; UID=XXXXXX; PWD=XXXXX;');
}
catch(PDOException $exception)
{
die("Unable to open database.<br />Error message:<br /><br />$exception.");
}
echo '<h1>Successfully connected!</h1>';
echo gettype($empid);
$query = "select Employee_ID from REPT_Employee where Employee_ID=$empid";
echo $query
**$statement = $db->prepare($query);** //Getting error in this line
$statement->execute();
$result = $statement->fetchAll(PDO::FETCH_NUM);
echo $result
?>
I Can't able to execute the query. Can anyone help me to find out what mistake i did.