I\'m testing out php 7 and have come across this error:
Fatal error: Uncaught Error: Call to undefined function odbc_connect()
From the doc page: http://php.
From php.ini file:
> ; Notes for Windows environments :
> ;
> ; - ODBC support is built in, so no dll is needed for it.
> ; - Many DLL files are located in the extensions/ (PHP 4) or ext/ (PHP 5+)
But, in PHP 7, ODBC is not by default. Explicit
extension=odbc
worked for me (new syntax recommended)
Edit: If your architecture is x64 you must use C:\Windows\SysWOW64\odbcad32.exe instead of C:\Windows\system32\odbcad32.exe
There is written in doc: ODBC support doesn't need any extension dll. It is true in PHP 5.x, I had to remove "extension=php_odbc.dll" from ini file.
But in PHP 7 I had to put it back.
I found the file "ext/php_odbc.dll" in the new PHP 7 directory again. It works for me :).
I ran into the same problem. However according to the link you provided PHP7 is in fact supported. So I'm not sure why you have so many comments telling you to go re-write your code.
This is what ultimately fixed the issue for me:
sudo apt-get install php-odbc
Followed by restarting Apache.
PHP 7.2.7, add extension=php_odbc.dll in php.ini file while either using database as MS Access or Sql Server C:\xxxxxx\php\php.ini
*no semicolon before to extension=php_odbc.dll
The DOC page does list PHP 7, so just install php-odbc and you should be good to go. Currently using it myself on RedHat EL7 with Remi php7.
Here is the error message:
Redhat PHP Fatal error: Uncaught Error: Call to undefined function odbc_connect()
On Redhat Linux 7 you run:
yum install php-odbc
You will get these packages marked in red:
Code sample to test your connection via php command line run: php [filename].php
<?php
// filename: test-connection.php by running command -> php test-connection.php
$connect = odbc_connect("Driver=FreeTDS; Server=sbase.company.ca; Port=1433; TDS_Version=8; ClientCharset=UTF-8; Database=mydbase",'company\\user', 'password');
$query = "SELECT * from mytable";
// perform the query
$result = odbc_exec($connect, $query);
// fetch the data from the database
while(odbc_fetch_row($result)){
$suid = odbc_result($result, 1);
$uid = odbc_result($result, 2);
$gid = odbc_result($result, 3);
$name = odbc_result($result, 4);
print("$name|$suid|$uid|$gid\n");
}
// close the connection
odbc_close($connect);
?>
Enjoy!