Bug #78423 [Nab]: ODBC functions work without extension=odbc
| From: | dpfender44 at gmail dot com | Date: | Sun, 18 Aug 2019 21:18:00 +0000 |
| Subject: | Bug #78423 [Nab]: ODBC functions work without extension=odbc | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-222311@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
User updated by: dpfender44 at gmail dot com
Reported by: dpfender44 at gmail dot com
Summary: ODBC functions work without extension=odbc
Status: Not a bug
Type: Bug
Package: ODBC related
Operating System: Windows 10
PHP Version: 7.4.0beta2
Block user comment: N
Private report: N
New Comment:
The only place php.ini files exist are in the directories that contain PHP programs (php.exe).
There are no registry keys or environment variables related to php.ini files. I do not know what
kind of search php.exe or php-cgi.exe does to find php.ini files. It must be Windows or IIS that
keeps a copy in cache and uses it when one is not found in the folder where php-cgi.exe exists. The
only thing that I can do with multiple versions of PHP on the same system is to make sure that a
php.ini file only exists in the one currently configured in IIS for Fast CGI processing.
Previous Comments:
------------------------------------------------------------------------
[2019-08-18 20:38:19] cmb@php.net
I suggest to check the php.ini search location docs[1]. If your
case isn't documented there, please report a respective doc bug.
Thanks.
[1] <https://www.php.net/manual/en/configuration.file.php>
------------------------------------------------------------------------
[2019-08-18 19:05:52] requinix@php.net
Good to hear you got that sorted out.
------------------------------------------------------------------------
[2019-08-18 18:27:09] dpfender44 at gmail dot com
I have solved the problem. I have 3 versions of PHP installed on my system in 3 folders: C:/PHP738,
C:/PHP739, C:/PHP740. I removed all php.ini files and then my script fails because odbc is not
loaded. I then added back the php.ini into C:/PHP738 (which has odbc enabled) and then the PHP
7.4.0 web server loads the php.ini info from folder C:/PHP738 and the script works. It must be
something in Windows or IIS that is finding a copy of php.ini in a cache and using it instead of
what is in the folder for the version of PHP being used by IIS.
Sorry for all the grief that I have caused, but this was a really strange situation.
------------------------------------------------------------------------
[2019-08-18 10:20:57] cmb@php.net
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>
------------------------------------------------------------------------
[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>
------------------------------------------------------------------------
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