Hi All,

Can anyone please help me.
I am trying to connect to a Pervasive SQL v9 database using a PHP script.
I have been trying for hours to make a connection but all my browsers keep loading with no response from the server.
The PHP code is as follows:

$sConnection = odbc_connect("DRIVER={Pervasive ODBC Engine Interface};ServerName=127.0.0.1;DBQ=wmtest;","Master","master");
if(!$sConnection) die("Could not connect<br>");
else die('Connected');

Strangely, i tried using this script on a Windows 7 machine, and it worked but now i am on a Windows Vista, it won't work.

Thanks in advance.

Dani AI

Generated

Nice troubleshooting by — the problem on Vista was almost certainly that the PHP/Apache process could not load the Pervasive ODBC client libraries even though the same script worked on the Windows 7 box. Common Windows causes are (1) a 32/64-bit mismatch between PHP/Apache and the Pervasive client, (2) the service/process environment not finding the vendor DLLs, and (3) missing VC++/runtime dependencies for those DLLs.

Quick checklist to reproduce and to make the fix robust

  • Confirm bitness: PHP/Apache and the Pervasive client must both be 32-bit or both 64-bit. Mismatches are the top cause.
  • Use the correct ODBC admin tool to view drivers (on 64-bit Windows you must use the 32-bit ODBC administrator to see 32-bit drivers).
  • Verify PHP actually has ODBC enabled and is loading the expected php.ini (create a phpinfo page and check the loaded configuration and enabled extensions).
  • Check Apache/PHP error logs and use ODBC diagnostic calls to capture driver errors rather than letting the browser hang. A hanging request often indicates the driver is waiting for a dependency or a network/service.
  • Prefer adding the vendor client folder to the System PATH or installing the official client package rather than scattering DLLs into PHP folders — that avoids version/permission problems and keeps updates consistent. After changing PATH or php.ini, restart the web service (or the machine) so the service picks up the changes.
  • If you still see failures, run Dependency Walker (matching the bitness) against the driver DLLs to reveal missing runtime libraries.

Small test: put a tiny phpinfo() page on the server to confirm which php.ini is used and whether ODBC support shows up. If further help is needed, include the PHP build (x86/x64), the webserver type (Apache/IIS), and any relevant Apache/PHP error log entries.

I think i finally solved the problem after some clues from the internet.
Solution:
I had to copy the 4 dll files:
- w3odbcci.dll
- w3odbccs.dll
- w3odbcei.dll
- w3odbces.dll
from the pervasive bin directory to a new folder c:\perv_ext\
I then included this directory in my php.ini file, by altering the 'extension_dir' to also include c:\perv_ext
I restarted my webserver, and i saw my script being executed and the connection had gone through.
Thanks.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.