Bug #78423 [Asn->Opn]: ODBC functions work without extension=odbc

From: Date: Sun, 18 Aug 2019 10:20:57 +0000
Subject: Bug #78423 [Asn->Opn]: ODBC functions work without extension=odbc
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-222305@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=78423&edit=1 ID: 78423 Updated by: cmb@php.net Reported by: dpfender44 at gmail dot com Summary: ODBC functions work without extension=odbc -Status: Assigned +Status: Open Type: Bug Package: PHP options/info functions Operating System: Windows 10 PHP Version: 7.4.0beta2 -Assigned To: cmb +Assigned To: Block user comment: N Private report: N New Comment: With the additional information, this looks like ODBC is not compiled statically. You can verify that with ProcessExplorer[1] which probably shows that php_odbc.dll is loaded. Anyhow, I actually tested with IIS now, and the ODBC extension is only available if I add extension=odbc to php.ini (and restart IIS). So this looks like a configuration issue on your machine. [1] <https://docs.microsoft.com/en-us/sysinternals/downloads/process-explorer> Previous Comments: ------------------------------------------------------------------------ [2019-08-17 19:15:01] dpfender44 at gmail dot com This is the PHP script that works without php.ini file. <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>ODBC Test 5</title> </head> <body> <?php if (!function_exists('odbc_connect')) { echo "<br><br><b>Function odbc_connect does not exist!</b><br>"; echo "Make sure that php.ini enables extension for odbc.<br>"; } else { $exprect_res_cnt = 2; $db_name = "test_db"; $db_table = 'test_info'; echo "<br><br>db name ({$db_name}), db table ({$db_table}), expect <b>res_cnt ({$exprect_res_cnt})</b><br>"; $server = 'djpnet5.dyndns.org'; $dsn = "Driver={MySQL ODBC 8.0 Unicode Driver};Server=$server;Database=$db_name;"; echo "<br><br>ODBC Connector string (<b>{$dsn})</b><br>"; $user = 'root3'; $password = "djp777!123"; $cid = @odbc_connect($dsn, $user, $password); if ($cid) { $qstr = "SELECT * FROM {$db_table}"; $res_id = odbc_prepare($cid, $qstr); if ($res_id) { $res = odbc_execute($res_id); if ($res) { $res_cnt = odbc_num_rows($res_id); echo "<br><br>got <b>res_cnt ({$res_cnt})</b><br>"; } else { echo "<br><br><b>Failed to execute!</b><br>"; } } else { echo "<br><br><b>Failed to prepare!</b><br>"; } } else { echo "<br><br><b>Failed to connect!</b><br>"; echo "Connection string ({$dsn})<br>"; } } ?> </body> </html> ------------------------------------------------------------------------ [2019-08-17 19:06:18] dpfender44 at gmail dot com C:\PHP740>php --ini Configuration File (php.ini) Path: C:\WINDOWS Loaded Configuration File: (none) Scan for additional .ini files in: (none) Additional .ini files parsed: (none) C:\PHP740>php.exe -n -m [PHP Modules] bcmath calendar Core ctype date dom filter hash iconv json libxml mysqlnd pcre PDO Phar readline Reflection session SimpleXML SPL standard tokenizer xml xmlreader xmlwriter zip zlib [Zend Modules] C:\PHP740>php-cgi.exe -n -m [PHP Modules] bcmath calendar cgi-fcgi Core ctype date dom filter hash iconv json libxml mysqlnd pcre PDO Phar readline Reflection session SimpleXML SPL standard tokenizer xml xmlreader xmlwriter zip zlib [Zend Modules] C:\PHP740> ------------------------------------------------------------------------ [2019-08-17 17:46:25] phpbugreports at gmail dot com what about compare the output of "php.exe -n -m" and "php-cgi.exe -n -m" so that you can easily bypass "seems" and "assumptions" ------------------------------------------------------------------------ [2019-08-17 17:41:42] dpfender44 at gmail dot com It seems that the php-cgi.exe has odbc included, but php.exe does not. ------------------------------------------------------------------------ [2019-08-17 17:36:06] dpfender44 at gmail dot com For PHP 7.4.0beta2, I removed the php.ini file and the odbc functions still work, but another script using mysqli_connect fails. C:\PHP740>php --ini Configuration File (php.ini) Path: C:\WINDOWS Loaded Configuration File: (none) Scan for additional .ini files in: (none) Additional .ini files parsed: (none) C:\PHP740> ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at https://bugs.php.net/bug.php?id=78423 -- Edit this bug report at https://bugs.php.net/bug.php?id=78423&edit=1

« previous php.bugs (#222305) next »