twdavis Posted December 20, 2023 Share Posted December 20, 2023 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 [FreeTDS] Description=FreeTDS Driver Driver=/usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so Setup=/usr/lib/x86_64-linux-gnu/odbc/libtdsS.so [ODBC Driver 18 for SQL Server] Description=Microsoft ODBC Driver 18 for SQL Server Driver=/opt/microsoft/msodbcsql18/lib64/libmsodbcsql-18.3.so.2.1 UsageCount=1 [ODBC Driver 17 for SQL Server] Description=Microsoft ODBC Driver 17 for SQL Server Driver=/opt/microsoft/msodbcsql17/lib64/libmsodbcsql-17.10.so.5.1 UsageCount=1 My odbc.ini [KF-M1] Driver=FreeTDS Trace=Yes Servername=KF-M1 Database=M1_KF Quote Link to comment https://forums.phpfreaks.com/topic/317557-sql-server-2019-odbc-connection-help/ Share on other sites More sharing options...
twdavis Posted December 20, 2023 Author Share Posted December 20, 2023 (edited) 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 <?php ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); //echo "Connection page"; $name = 'kf-m1'; $user = 'user'; $password = 'password'; $hostname='ipaddress'; $dbname='M1_KF'; $username='user'; $password='password'; $connect =odbc_connect($name,$user,$password); if(!$connect) { exit("Connection Failed: " . $connect); }; ?> Edited December 20, 2023 by twdavis Quote Link to comment https://forums.phpfreaks.com/topic/317557-sql-server-2019-odbc-connection-help/#findComment-1613679 Share on other sites More sharing options...
kicken Posted December 20, 2023 Share Posted December 20, 2023 You need to install the ODBC extension on your system. For example, with apt install php-odbc on something Debian based should do it. Quote Link to comment https://forums.phpfreaks.com/topic/317557-sql-server-2019-odbc-connection-help/#findComment-1613681 Share on other sites More sharing options...
twdavis Posted December 20, 2023 Author Share Posted December 20, 2023 I have the odbc extension installed and can connect to sql server 2008 with no problem. in this same connection page if I change to the old server is works fine. Quote Link to comment https://forums.phpfreaks.com/topic/317557-sql-server-2019-odbc-connection-help/#findComment-1613683 Share on other sites More sharing options...
twdavis Posted December 20, 2023 Author Share Posted December 20, 2023 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. Error: 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';?> </head> <body> <?php $gr_total = 0; $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); if(!$result){ 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']; } odbc_close($connect); $gr_total=number_format($total,2); echo "Total"." ". $gr_total ?> Quote Link to comment https://forums.phpfreaks.com/topic/317557-sql-server-2019-odbc-connection-help/#findComment-1613684 Share on other sites More sharing options...
Solution twdavis Posted December 21, 2023 Author Solution Share Posted December 21, 2023 I deleted the swl user and created a new on e and it fix the problem. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/317557-sql-server-2019-odbc-connection-help/#findComment-1613713 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.