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
?>