Jump to content

Sql Server 2019 odbc connection help

Go to solution Solved by twdavis,

Recommended Posts

I can connect to the sql server 2019  from my linux machine with tsql but not with isql or with PHP odbc_connect. I can connect to older SQL Servers. I have tried a lot of different thing including FreeTDS. isql error is [ISQL]ERROR: Could not SQLConnect

my odbcinst.ini

Description=FreeTDS Driver

[ODBC Driver 18 for SQL Server]
Description=Microsoft ODBC Driver 18 for SQL Server

[ODBC Driver 17 for SQL Server]
Description=Microsoft ODBC Driver 17 for SQL Server

My odbc.ini


Link to comment
Share on other sites


PHP Fatal error:  Uncaught Error: Call to undefined function odbc_connect() in /var/www/html/V9/connection.php:19
Stack trace:
#0 {main}
  thrown in /var/www/html/V9/connection.phpI get this error from PHP Connection 

my php Connect


ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
//echo "Connection page";

$name = 'kf-m1';
$user = 'user';
$password = 'password';


$connect =odbc_connect($name,$user,$password);
if(!$connect) {
    exit("Connection Failed: " . $connect);



Edited by twdavis
Link to comment
Share on other sites

Run this code pointing to the new SQL server I get and error. But pointing to the old SQL server it works fine. and line 24 is the odbc_connect.


Warning: odbc_exec(): SQL error: [FreeTDS]

The cursor was not declared., SQL state 37000 in SQLExecDirect in /var/www/html/V9/bs_kf_orders_shipped_sum1.php on line 24
Error in SQL
   <?php include 'connection.php';?>

$gr_total = 0;
$sql="  select
  impPartClassID,sum(omlExtendedPriceBase) as Total1 ,sum(omlQuantityShipped) as qty
  from m1_kf.dbo.SalesOrders
left outer join m1_kf.dbo.SalesOrderLines on omlSalesOrderID=ompSalesOrderID
Left Outer join m1_kf.dbo.Parts on impPartID=omlpartid
LEFT JOIN m1_KF.dbo.Organizations og ON cmoOrganizationID = ompShipOrganizationID
 where ompcloseddate= '12-05-2023' and omlQuantityShipped !=0

group by impPartClassID";
$result =odbc_exec($connect,$sql);
exit("Error in SQL");
 while ($row = odbc_fetch_array($result))
echo "<tr><td>" . $row['impPartClassID'] ."</td>";
echo "<td>" . number_format($row['Total1'],2) ."  "."</td>";
echo "<td>" ." Qty ".number_format($row['qty'],0)."<br></td></tr>"; 
$total = $total + $row['Total1'];    

echo "Total"."  ". $gr_total 


Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.