0

Fatal error: Uncaught Error: Call to undefined function odbc_connect() in C:\xampp\htdocs\simrs\tes.php:8 Stack trace: #0 {main} thrown in C:\xampp\htdocs\simrs\tes.php on line 8

I tried to write this

$server="myservername";
$username="myusername";
$password="mypassword";
$db="mydb";
$connection_string = "DRIVER={ODBC DRIVER 17 for SQL Server};SERVER=$server;PORT:myPort;DATABASE=$db";
$odbcConn = odbc_connect($connection_string,$username,$password); `

But that always fatal error.

I already installed ODBC driver. I don't actually know what caused this.

This is my ODBC installer

Dale K
  • 25,246
  • 15
  • 42
  • 71
  • Aside... there's no `Port` connection string property for the SQL Server drivers and even if there were it would be `Port=myPortNumber;` as opposed to `Port:myPortNumber;`. If you need to specify a port number other than the default 1433 it gets included in the `SERVER` property, e.g.: `Server=tcp:serverNameOrIpAddress,myPortNumber;`. – AlwaysLearning Jan 08 '23 at 07:30
  • Do you have `php-odbc` installed and configured in your `php.ini` file? It may have been configured by default in PHP 5.1, but maybe not in PHP 7 and 8. See also: [Call to undefined function odbc_connect() php 7](https://stackoverflow.com/questions/34321203). – AlwaysLearning Jan 08 '23 at 07:32

0 Answers0